-
Notifications
You must be signed in to change notification settings - Fork 295
Expand file tree
/
Copy pathflake.nix
More file actions
140 lines (129 loc) · 3.78 KB
/
flake.nix
File metadata and controls
140 lines (129 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{
description = "Flake for c2rust";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
utils,
fenix,
}:
utils.lib.eachDefaultSystem (
system:
let
fenixToolchain =
let
toml = with builtins; (fromTOML (readFile ./rust-toolchain.toml)).toolchain;
in
(fenix.packages.${system}.fromToolchainName {
name = toml.channel;
sha256 = "sha256-r/8YBFuFa4hpwgE3FnME7nQA2Uc1uqj0eCE1NWmI1u0";
})."completeToolchain";
pkgs = import nixpkgs {
inherit system;
overlays = [ ];
config = {
allowUnfree = true;
};
};
myLLVM = pkgs.llvmPackages;
myStdenv = pkgs.clangStdenv;
rustPlatform = pkgs.makeRustPlatform {
cargo = fenixToolchain;
rustc = fenixToolchain;
};
env = {
CMAKE_LLVM_DIR = "${myLLVM.libllvm.dev}/lib/cmake/llvm";
CMAKE_CLANG_DIR = "${myLLVM.libclang.dev}/lib/cmake/clang";
LLVM_CONFIG_PATH = "${myLLVM.libllvm.dev}/bin/llvm-config";
CLANG_PATH = "${myLLVM.clang}/bin/clang";
TINYCBOR_DIR = "${pkgs.tinycbor}";
NIX_ENFORCE_NO_NATIVE = 0; # Enable SSE instructions.
# Enable nix in the c2rust test suite
# This flag is used to tell the test scripts to look for
# libraries under nix paths.
C2RUST_USE_NIX = 1;
RUST_SRC_PATH = "${fenixToolchain}/lib/rustlib/src/rust/library";
};
in
rec {
packages = {
default = rustPlatform.buildRustPackage (
with pkgs;
env
// {
pname = "c2rust";
version = "0.20.0";
src = ./.;
doCheck = false; # Can use checkFlags to disable specific tests
patches = [ ./nix-tinycbor-cmake.patch ];
nativeBuildInputs = with pkgs; [
pkg-config
cmake
uv
(python3.withPackages (
python-pkgs: with python-pkgs; [
"bencode-python3"
cbor
colorlog
mako
pip
plumbum
psutil
pygments
typing
"scan-build"
pyyaml
toml
]
))
myStdenv.cc
myLLVM.libclang
myLLVM.clang
myLLVM.llvm
myLLVM.libllvm
];
buildInputs = with pkgs; [
curl.dev
rustPlatform.bindgenHook
myStdenv.cc
myLLVM.libclang
myLLVM.clang
myLLVM.llvm
myLLVM.libllvm
tinycbor
openssl
zlib
fenixToolchain
z3.dev
];
cargoLock = {
lockFile = ./Cargo.lock;
};
}
);
};
defaultPackage = packages.default;
devShells = {
# Include a fixed version of clang in the development environment for testing.
default = pkgs.mkShell (
with pkgs;
env
// {
strictDeps = true;
inputsFrom = [ packages.default ];
buildInputs = [ ];
}
);
};
devShell = devShells.default;
}
);
}