nix: only set CONDUIT_VERSION_EXTRA for final build + slight cleanup

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-05-01 12:37:03 -04:00 committed by June
parent 096c252dc2
commit db81ffb4ea

View file

@ -1,7 +1,6 @@
{ inputs # Dependencies (keep sorted)
{ craneLib
# Dependencies , inputs
, craneLib
, lib , lib
, libiconv , libiconv
, pkgsBuildHost , pkgsBuildHost
@ -9,54 +8,72 @@
, rust , rust
, stdenv , stdenv
# Options # Options (keep sorted)
, default_features ? true , default_features ? true
, features ? [] , features ? []
, profile ? "release" , profile ? "release"
}: }:
craneLib.buildPackage rec { let
src = inputs.nix-filter { buildDepsOnlyEnv =
root = inputs.self; let
include = [ rocksdb' = rocksdb.override {
"src" enableJemalloc = builtins.elem "jemalloc" features;
"hot_lib" };
"Cargo.toml" in
"Cargo.lock" {
]; CARGO_PROFILE = profile;
}; ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include";
ROCKSDB_LIB_DIR = "${rocksdb'}/lib";
}
//
(import ./cross-compilation-env.nix {
# Keep sorted
inherit
lib
pkgsBuildHost
rust
stdenv;
});
# This is redundant with CI buildPackageEnv = {
doCheck = false; CONDUIT_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev;
} // buildDepsOnlyEnv;
env = commonAttrs = {
let inherit
rocksdb' = rocksdb.override { (craneLib.crateNameFromCargoToml {
enableJemalloc = builtins.elem "jemalloc" features; cargoToml = "${inputs.self}/Cargo.toml";
}; })
in pname
{ version;
CARGO_PROFILE = profile;
CONDUIT_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev;
ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include";
ROCKSDB_LIB_DIR = "${rocksdb'}/lib";
}
//
(import ./cross-compilation-env.nix {
inherit
lib
pkgsBuildHost
rust
stdenv;
});
nativeBuildInputs = [ src = let filter = inputs.nix-filter.lib; in filter {
# bindgen needs the build platform's libclang. Apparently due to "splicing root = inputs.self;
# weirdness", pkgs.rustPlatform.bindgenHook on its own doesn't quite do the
# right thing here. # Keep sorted
pkgsBuildHost.rustPlatform.bindgenHook include = [
"Cargo.lock"
"Cargo.toml"
"hot_lib"
"src"
];
};
nativeBuildInputs = [
# bindgen needs the build platform's libclang. Apparently due to "splicing
# weirdness", pkgs.rustPlatform.bindgenHook on its own doesn't quite do the
# right thing here.
pkgsBuildHost.rustPlatform.bindgenHook
] ]
++ lib.optionals stdenv.isDarwin [ libiconv ]; ++ lib.optionals stdenv.isDarwin [ libiconv ];
};
in
craneLib.buildPackage ( commonAttrs // {
cargoArtifacts = craneLib.buildDepsOnly (commonAttrs // {
env = buildDepsOnlyEnv;
});
cargoExtraArgs = "" cargoExtraArgs = ""
+ lib.optionalString + lib.optionalString
@ -66,11 +83,14 @@ craneLib.buildPackage rec {
(features != []) (features != [])
"--features " + (builtins.concatStringsSep "," features); "--features " + (builtins.concatStringsSep "," features);
meta.mainProgram = (craneLib.crateNameFromCargoToml { # This is redundant with CI
cargoToml = "${inputs.self}/Cargo.toml"; doCheck = false;
}).pname;
env = buildPackageEnv;
passthru = { passthru = {
inherit env; env = buildPackageEnv;
}; };
}
meta.mainProgram = commonAttrs.pname;
})