Skip to content

Commit c6610d5

Browse files
authored
Fix Nix (#1094)
The current nix expression doesn't build for me on nixos on 23.11 stable (bunch of various build errors that I can share if useful). This nix flake builds the project without erroring (e.g. `nix develop -c cargo build --release`) and also brings in the rust toolchain declaratively with nix instead of with rustup.
2 parents 73bdbb8 + df915a1 commit c6610d5

File tree

2 files changed

+242
-0
lines changed

2 files changed

+242
-0
lines changed

flake.lock

+183
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
description = "Flake for c2rust";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
6+
utils.url = "github:numtide/flake-utils";
7+
fenix = {
8+
url = "github:nix-community/fenix";
9+
};
10+
oxalica = {
11+
url = "github:oxalica/rust-overlay";
12+
};
13+
};
14+
15+
outputs = inputs@{ self, nixpkgs, utils, fenix, oxalica}:
16+
utils.lib.eachDefaultSystem (system:
17+
let
18+
fenixStable = fenix.packages.${system}.fromToolchainFile {
19+
file = ./rust-toolchain.toml;
20+
sha256 = "sha256-r/8YBFuFa4hpwgE3FnME7nQA2Uc1uqj0eCE1NWmI1u0";
21+
};
22+
pkgs = import nixpkgs {
23+
inherit system;
24+
overlays = [
25+
(import oxalica)
26+
];
27+
config = {
28+
allowUnfree = true;
29+
};
30+
};
31+
in {
32+
defaultPackage = self.devShell.${system};
33+
devShell = pkgs.mkShell.override { } {
34+
35+
LIBCLANG_PATH = "${pkgs.llvmPackages_14.libclang.lib}/lib";
36+
CMAKE_LLVM_DIR = "${pkgs.llvmPackages_14.libllvm.dev}/lib/cmake/llvm";
37+
CMAKE_CLANG_DIR = "${pkgs.llvmPackages_14.libclang.dev}/lib/cmake/clang";
38+
shellHook = ''
39+
export CARGO_TARGET_DIR="$(git rev-parse --show-toplevel)/target_dirs/nix_rustc";
40+
'';
41+
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
42+
buildInputs =
43+
with pkgs; [
44+
clangStdenv.cc
45+
llvmPackages_14.libclang
46+
pkg-config
47+
fenix.packages.${system}.rust-analyzer
48+
llvmPackages_14.clang
49+
cmake
50+
llvmPackages_14.llvm
51+
llvmPackages_14.libllvm
52+
openssl
53+
python3
54+
zlib
55+
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
56+
];
57+
};
58+
});
59+
}

0 commit comments

Comments
 (0)