Skip to content

Commit

Permalink
Merge pull request #123 from winterqt/fix-build-on-newer-nix
Browse files Browse the repository at this point in the history
Fix build on Nix 2.19+
  • Loading branch information
zhaofengli authored Mar 29, 2024
2 parents 6eabc3f + 657db64 commit 4dbdbee
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
3 changes: 3 additions & 0 deletions attic/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ fn build_bridge() {
.flag("nix/config.h")
.flag("-idirafter")
.flag(hacky_include.path().to_str().unwrap())
// In Nix 2.19+, nix/args/root.hh depends on being able to #include "root.hh" (which is in its parent directory), for some reason
.flag("-I")
.flag(concat!(env!("NIX_INCLUDE_PATH"), "/nix"))
.compile("nixbinding");

println!("cargo:rerun-if-changed=src/nix_store/bindings");
Expand Down
14 changes: 5 additions & 9 deletions crane.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ let

ATTIC_DISTRIBUTOR = "attic";

# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
# See comment in `attic/build.rs`
NIX_INCLUDE_PATH = "${lib.getDev nix}/include";

# See comment in `attic-tests`
doCheck = false;
Expand Down Expand Up @@ -135,17 +133,15 @@ let

nativeBuildInputs = nativeBuildInputs ++ [ jq ];

# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};

doCheck = true;

buildPhaseCargoCommand = "";
checkPhaseCargoCommand = "cargoWithProfile test --no-run --message-format=json >cargo-test.json";
doInstallCargoArtifacts = false;

# See comment in `attic/build.rs`
NIX_INCLUDE_PATH = "${lib.getDev nix}/include";

installPhase = ''
runHook preInstall
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

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

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
NIX_PATH = "nixpkgs=${pkgs.path}";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library";

# See comment in `attic/build.rs`
NIX_INCLUDE_PATH = "${lib.getDev pkgs.nix}/include";

ATTIC_DISTRIBUTOR = "dev";
};

Expand Down
6 changes: 2 additions & 4 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ in rustPlatform.buildRustPackage rec {

ATTIC_DISTRIBUTOR = "attic";

# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};
# See comment in `attic/build.rs`
NIX_INCLUDE_PATH = "${lib.getDev nix}/include";

# Recursive Nix is not stable yet
doCheck = false;
Expand Down

0 comments on commit 4dbdbee

Please sign in to comment.