From 657db64e51cceef71a0c910bad485dab00163843 Mon Sep 17 00:00:00 2001 From: Winter Date: Wed, 27 Mar 2024 17:14:45 -0400 Subject: [PATCH] Fix build on Nix 2.19+ Nix 2.19 introduced a change [0] that broke how we compile our libnixstore bindings, which requires adding an additional include directory when we compile them. [0]: https://github.com/NixOS/nix/commit/b461cac21aa5b9127d230ed3f1a1ca8e8266fb60 --- attic/build.rs | 3 +++ crane.nix | 6 ++++++ flake.nix | 3 +++ package.nix | 3 +++ 4 files changed, 15 insertions(+) diff --git a/attic/build.rs b/attic/build.rs index 3da0fed..da27f7d 100644 --- a/attic/build.rs +++ b/attic/build.rs @@ -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"); diff --git a/crane.nix b/crane.nix index 0c02289..4ec2827 100644 --- a/crane.nix +++ b/crane.nix @@ -62,6 +62,9 @@ let ATTIC_DISTRIBUTOR = "attic"; + # See comment in `attic/build.rs` + NIX_INCLUDE_PATH = "${lib.getDev nix}/include"; + # See comment in `attic-tests` doCheck = false; @@ -136,6 +139,9 @@ let 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 diff --git a/flake.nix b/flake.nix index c8317d7..ea81e6f 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; }; diff --git a/package.nix b/package.nix index 1770f68..e40c765 100644 --- a/package.nix +++ b/package.nix @@ -49,6 +49,9 @@ in rustPlatform.buildRustPackage rec { ATTIC_DISTRIBUTOR = "attic"; + # See comment in `attic/build.rs` + NIX_INCLUDE_PATH = "${lib.getDev nix}/include"; + # Recursive Nix is not stable yet doCheck = false;