2024-05-01 16:37:03 +00:00
|
|
|
# Dependencies (keep sorted)
|
|
|
|
{ craneLib
|
|
|
|
, inputs
|
2024-04-21 22:28:35 +00:00
|
|
|
, lib
|
|
|
|
, libiconv
|
|
|
|
, pkgsBuildHost
|
|
|
|
, rocksdb
|
|
|
|
, rust
|
|
|
|
, stdenv
|
|
|
|
|
2024-05-01 16:37:03 +00:00
|
|
|
# Options (keep sorted)
|
2024-04-25 02:51:19 +00:00
|
|
|
, default_features ? true
|
2024-04-21 22:28:35 +00:00
|
|
|
, features ? []
|
|
|
|
, profile ? "release"
|
|
|
|
}:
|
|
|
|
|
2024-05-01 16:37:03 +00:00
|
|
|
let
|
|
|
|
buildDepsOnlyEnv =
|
|
|
|
let
|
|
|
|
rocksdb' = rocksdb.override {
|
|
|
|
enableJemalloc = builtins.elem "jemalloc" features;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
});
|
2024-04-21 22:28:35 +00:00
|
|
|
|
2024-05-01 16:37:03 +00:00
|
|
|
buildPackageEnv = {
|
2024-04-27 01:38:29 +00:00
|
|
|
CONDUWUIT_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
|
2024-05-01 16:37:03 +00:00
|
|
|
} // buildDepsOnlyEnv;
|
|
|
|
|
|
|
|
commonAttrs = {
|
|
|
|
inherit
|
|
|
|
(craneLib.crateNameFromCargoToml {
|
|
|
|
cargoToml = "${inputs.self}/Cargo.toml";
|
|
|
|
})
|
|
|
|
pname
|
|
|
|
version;
|
|
|
|
|
|
|
|
src = let filter = inputs.nix-filter.lib; in filter {
|
|
|
|
root = inputs.self;
|
2024-04-21 22:28:35 +00:00
|
|
|
|
2024-05-01 16:37:03 +00:00
|
|
|
# Keep sorted
|
|
|
|
include = [
|
|
|
|
"Cargo.lock"
|
|
|
|
"Cargo.toml"
|
|
|
|
"hot_lib"
|
|
|
|
"src"
|
|
|
|
];
|
|
|
|
};
|
2024-04-21 22:28:35 +00:00
|
|
|
|
2024-05-01 16:37:03 +00:00
|
|
|
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
|
2024-04-21 22:28:35 +00:00
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ libiconv ];
|
2024-05-01 16:37:03 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
craneLib.buildPackage ( commonAttrs // {
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly (commonAttrs // {
|
|
|
|
env = buildDepsOnlyEnv;
|
|
|
|
});
|
2024-04-21 22:28:35 +00:00
|
|
|
|
|
|
|
cargoExtraArgs = ""
|
2024-04-25 02:51:19 +00:00
|
|
|
+ lib.optionalString
|
|
|
|
(!default_features)
|
|
|
|
"--no-default-features "
|
2024-04-21 22:28:35 +00:00
|
|
|
+ lib.optionalString
|
|
|
|
(features != [])
|
|
|
|
"--features " + (builtins.concatStringsSep "," features);
|
|
|
|
|
2024-05-03 07:35:36 +00:00
|
|
|
# This is redundant with CI
|
|
|
|
cargoTestCommand = "";
|
|
|
|
|
2024-05-01 16:37:03 +00:00
|
|
|
# This is redundant with CI
|
|
|
|
doCheck = false;
|
|
|
|
|
2024-05-03 16:05:01 +00:00
|
|
|
# https://crane.dev/faq/rebuilds-bindgen.html
|
|
|
|
NIX_OUTPATH_USED_AS_RANDOM_SEED = "aaaaaaaaaa";
|
|
|
|
|
2024-05-01 16:37:03 +00:00
|
|
|
env = buildPackageEnv;
|
2024-04-21 22:28:35 +00:00
|
|
|
|
|
|
|
passthru = {
|
2024-05-01 16:37:03 +00:00
|
|
|
env = buildPackageEnv;
|
2024-04-21 22:28:35 +00:00
|
|
|
};
|
2024-05-01 16:37:03 +00:00
|
|
|
|
|
|
|
meta.mainProgram = commonAttrs.pname;
|
|
|
|
})
|