diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2020-02-11 11:48:45 +0100 |
---|---|---|
committer | Andreas Rammhold <andreas@rammhold.de> | 2020-02-11 11:48:45 +0100 |
commit | be5597fc9d2f4fefac097d3c6e9364bedf548078 (patch) | |
tree | 4cdb1cacdf28b0ccca932029c662514227aec16e /pkgs/build-support | |
parent | 157f392f57ddcb3a0c8b7062dc01469c6b43fdce (diff) | |
download | nixlib-be5597fc9d2f4fefac097d3c6e9364bedf548078.tar nixlib-be5597fc9d2f4fefac097d3c6e9364bedf548078.tar.gz nixlib-be5597fc9d2f4fefac097d3c6e9364bedf548078.tar.bz2 nixlib-be5597fc9d2f4fefac097d3c6e9364bedf548078.tar.lz nixlib-be5597fc9d2f4fefac097d3c6e9364bedf548078.tar.xz nixlib-be5597fc9d2f4fefac097d3c6e9364bedf548078.tar.zst nixlib-be5597fc9d2f4fefac097d3c6e9364bedf548078.zip |
buildRustCrate: remove superfluous dependency overrides
By overriding each dependency on every level of the dependency tree we are creating a lot of unnecessary instances of the same derivation Looking at the output size of `nix-instantiate --trace-function-calls -vvvv …` and the execution time I got about a 10x improvement after applying this change. It was probably good intentions that lead to these overrides but in practice no tooling (that I know of) really needs this. `carnix` and `crate2nix` are fine without those overrides. Furthermore I believe that it is the job of the tooling around `buildRustCrate` to provide a coherent set of overrides. By not enforcing all of the overrides, debug flags, verbosity, … to be the same throughout the closure we also allow consumers to override specific aspects of the crates. Some (older?) crates might need different `crateOverrides` then newer crates with the same name. Currently such situations can not (easily) be implemented with the override in-place.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/rust/build-rust-crate/default.nix | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/pkgs/build-support/rust/build-rust-crate/default.nix b/pkgs/build-support/rust/build-rust-crate/default.nix index 569b48d25aea..94b64a1225cb 100644 --- a/pkgs/build-support/rust/build-rust-crate/default.nix +++ b/pkgs/build-support/rust/build-rust-crate/default.nix @@ -62,9 +62,6 @@ let crate = crate_ // (lib.attrByPath [ crate_.crateName ] (attr: {}) crateOverr extraRustcOpts_ = extraRustcOpts; buildTests_ = buildTests; - # take a list of crates that we depend on and override them to fit our overrides, rustc, release, … - makeDependencies = map (dep: lib.getLib (dep.override { inherit release verbose crateOverrides; })); - # crate2nix has a hack for the old bash based build script that did split # entries at `,`. No we have to work around that hack. # https://github.com/kolloch/crate2nix/blame/5b19c1b14e1b0e5522c3e44e300d0b332dc939e7/crate2nix/templates/build.nix.tera#L89 @@ -93,8 +90,8 @@ stdenv.mkDerivation (rec { name = "rust_${crate.crateName}-${crate.version}${lib.optionalString buildTests_ "-test"}"; depsBuildBuild = [ rust stdenv.cc ]; buildInputs = (crate.buildInputs or []) ++ buildInputs_; - dependencies = makeDependencies dependencies_; - buildDependencies = makeDependencies buildDependencies_; + dependencies = map lib.getLib dependencies_; + buildDependencies = map lib.getLib buildDependencies_; completeDeps = lib.unique (dependencies ++ lib.concatMap (dep: dep.completeDeps) dependencies); completeBuildDeps = lib.unique ( |