Skip to content

Commit

Permalink
Fix Nix (#1094)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kkysen authored Sep 22, 2024
2 parents 73bdbb8 + df915a1 commit c6610d5
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 0 deletions.
183 changes: 183 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
description = "Flake for c2rust";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
};
oxalica = {
url = "github:oxalica/rust-overlay";
};
};

outputs = inputs@{ self, nixpkgs, utils, fenix, oxalica}:
utils.lib.eachDefaultSystem (system:
let
fenixStable = fenix.packages.${system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-r/8YBFuFa4hpwgE3FnME7nQA2Uc1uqj0eCE1NWmI1u0";
};
pkgs = import nixpkgs {
inherit system;
overlays = [
(import oxalica)
];
config = {
allowUnfree = true;
};
};
in {
defaultPackage = self.devShell.${system};
devShell = pkgs.mkShell.override { } {

LIBCLANG_PATH = "${pkgs.llvmPackages_14.libclang.lib}/lib";
CMAKE_LLVM_DIR = "${pkgs.llvmPackages_14.libllvm.dev}/lib/cmake/llvm";
CMAKE_CLANG_DIR = "${pkgs.llvmPackages_14.libclang.dev}/lib/cmake/clang";
shellHook = ''
export CARGO_TARGET_DIR="$(git rev-parse --show-toplevel)/target_dirs/nix_rustc";
'';
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
buildInputs =
with pkgs; [
clangStdenv.cc
llvmPackages_14.libclang
pkg-config
fenix.packages.${system}.rust-analyzer
llvmPackages_14.clang
cmake
llvmPackages_14.llvm
llvmPackages_14.libllvm
openssl
python3
zlib
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
];
};
});
}

0 comments on commit c6610d5

Please sign in to comment.