From 2e6bf86a423650e238ad633874017fe306b19f38 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Thu, 24 Oct 2024 14:51:16 -0700 Subject: [PATCH] move rust-jemalloc-sys to its own file --- flake.nix | 4 ++++ nix/pkgs/default/default.nix | 14 ++------------ nix/pkgs/rust-jemalloc-sys/default.nix | 12 ++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 nix/pkgs/rust-jemalloc-sys/default.nix diff --git a/flake.nix b/flake.nix index 80621ee3..d8e4365a 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,10 @@ default = prev.default.override args; }); + rust-jemalloc-sys = self.callPackage ./nix/pkgs/rust-jemalloc-sys { + inherit (pkgs) rust-jemalloc-sys; + }; + shell = self.callPackage ./nix/shell.nix {}; # The Rust toolchain to use diff --git a/nix/pkgs/default/default.nix b/nix/pkgs/default/default.nix index 67b55b95..d46a3d81 100644 --- a/nix/pkgs/default/default.nix +++ b/nix/pkgs/default/default.nix @@ -34,20 +34,10 @@ let featureEnabled = feature : builtins.elem feature features'; - # This derivation will set the JEMALLOC_OVERRIDE variable, causing the - # tikv-jemalloc-sys crate to use the nixpkgs jemalloc instead of building it's - # own. In order for this to work, we need to set flags on the build that match - # whatever flags tikv-jemalloc-sys was going to use. These are dependent on - # which features we enable in tikv-jemalloc-sys. - rust-jemalloc-sys' = (rust-jemalloc-sys.override { - # tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms feature - unprefixed = true; - }); - buildDepsOnlyEnv = let rocksdb' = rocksdb.override { - jemalloc = rust-jemalloc-sys'; + jemalloc = rust-jemalloc-sys; enableJemalloc = featureEnabled "jemalloc"; enableLiburing = false; }; @@ -92,7 +82,7 @@ let dontStrip = profile == "dev"; - buildInputs = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys'; + buildInputs = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys; nativeBuildInputs = [ # bindgen needs the build platform's libclang. Apparently due to "splicing diff --git a/nix/pkgs/rust-jemalloc-sys/default.nix b/nix/pkgs/rust-jemalloc-sys/default.nix new file mode 100644 index 00000000..7d1b178d --- /dev/null +++ b/nix/pkgs/rust-jemalloc-sys/default.nix @@ -0,0 +1,12 @@ +# This derivation will set the JEMALLOC_OVERRIDE variable, causing the +# tikv-jemalloc-sys crate to use the nixpkgs jemalloc instead of building it's +# own. In order for this to work, we need to set flags on the build that match +# whatever flags tikv-jemalloc-sys was going to use. These are dependent on +# which features we enable in tikv-jemalloc-sys. + +{ rust-jemalloc-sys }: + +rust-jemalloc-sys.override { + # tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms feature + unprefixed = true; +}