mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-01-04 00:43:10 +03:00
96cc1f6abd
This prevents us from needing to recompile the dependencies when that environment variable changes, which generally changes on every commit, which is far more frequently than the dependencies are actually changed.
94 lines
1.9 KiB
Nix
94 lines
1.9 KiB
Nix
# Dependencies (keep sorted)
|
|
{ craneLib
|
|
, inputs
|
|
, lib
|
|
, pkgsBuildHost
|
|
, rocksdb
|
|
, rust
|
|
, stdenv
|
|
|
|
# Options (keep sorted)
|
|
, default-features ? true
|
|
, features ? []
|
|
, profile ? "release"
|
|
}:
|
|
|
|
let
|
|
buildDepsOnlyEnv =
|
|
let
|
|
rocksdb' = rocksdb.override {
|
|
enableJemalloc = builtins.elem "jemalloc" features;
|
|
};
|
|
in
|
|
{
|
|
ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include";
|
|
ROCKSDB_LIB_DIR = "${rocksdb'}/lib";
|
|
}
|
|
//
|
|
(import ./cross-compilation-env.nix {
|
|
# Keep sorted
|
|
inherit
|
|
lib
|
|
pkgsBuildHost
|
|
rust
|
|
stdenv;
|
|
});
|
|
|
|
buildPackageEnv = {
|
|
CONDUIT_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev;
|
|
} // buildDepsOnlyEnv;
|
|
|
|
commonAttrs = {
|
|
inherit
|
|
(craneLib.crateNameFromCargoToml {
|
|
cargoToml = "${inputs.self}/Cargo.toml";
|
|
})
|
|
pname
|
|
version;
|
|
|
|
src = let filter = inputs.nix-filter.lib; in filter {
|
|
root = inputs.self;
|
|
|
|
# Keep sorted
|
|
include = [
|
|
"Cargo.lock"
|
|
"Cargo.toml"
|
|
"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
|
|
];
|
|
|
|
CARGO_PROFILE = profile;
|
|
};
|
|
in
|
|
|
|
craneLib.buildPackage ( commonAttrs // {
|
|
cargoArtifacts = craneLib.buildDepsOnly (commonAttrs // {
|
|
env = buildDepsOnlyEnv;
|
|
});
|
|
|
|
cargoExtraArgs = "--locked "
|
|
+ lib.optionalString
|
|
(!default-features)
|
|
"--no-default-features "
|
|
+ lib.optionalString
|
|
(features != [])
|
|
"--features " + (builtins.concatStringsSep "," features);
|
|
|
|
# This is redundant with CI
|
|
doCheck = false;
|
|
|
|
env = buildPackageEnv;
|
|
|
|
passthru = {
|
|
env = buildPackageEnv;
|
|
};
|
|
|
|
meta.mainProgram = commonAttrs.pname;
|
|
})
|