summary refs log tree commit diff
path: root/pkgs/build-support/rust/build-rust-crate
diff options
context:
space:
mode:
authorAndreas Rammhold <andreas@rammhold.de>2019-12-11 22:59:19 +0100
committerAndreas Rammhold <andreas@rammhold.de>2019-12-11 23:23:55 +0100
commitf4aeabd04a6f5c0daffebce808e0ea0301266af0 (patch)
treec1d680e24038fb292bb152b12ef300408eab2830 /pkgs/build-support/rust/build-rust-crate
parentdb55d1f89d3ee2aa0019aceb40c233d509eb2811 (diff)
downloadnixpkgs-f4aeabd04a6f5c0daffebce808e0ea0301266af0.tar
nixpkgs-f4aeabd04a6f5c0daffebce808e0ea0301266af0.tar.gz
nixpkgs-f4aeabd04a6f5c0daffebce808e0ea0301266af0.tar.bz2
nixpkgs-f4aeabd04a6f5c0daffebce808e0ea0301266af0.tar.lz
nixpkgs-f4aeabd04a6f5c0daffebce808e0ea0301266af0.tar.xz
nixpkgs-f4aeabd04a6f5c0daffebce808e0ea0301266af0.tar.zst
nixpkgs-f4aeabd04a6f5c0daffebce808e0ea0301266af0.zip
buildRustCrate: document and cleanup the symbol seeding
That code had been in the derivation for a while but no explanation was
given why that is needed. It might be helpful to our future selfs to
document why things are done the way they are.
Diffstat (limited to 'pkgs/build-support/rust/build-rust-crate')
-rw-r--r--pkgs/build-support/rust/build-rust-crate/default.nix9
1 files changed, 7 insertions, 2 deletions
diff --git a/pkgs/build-support/rust/build-rust-crate/default.nix b/pkgs/build-support/rust/build-rust-crate/default.nix
index 67e2106ef98..7cd99324dbc 100644
--- a/pkgs/build-support/rust/build-rust-crate/default.nix
+++ b/pkgs/build-support/rust/build-rust-crate/default.nix
@@ -93,8 +93,13 @@ stdenv.mkDerivation (rec {
     libName = if crate ? libName then crate.libName else crate.crateName;
     libPath = if crate ? libPath then crate.libPath else "";
 
-    depsMetadata = lib.foldl' (str: dep: str + dep.metadata) "" (dependencies ++ buildDependencies);
-    metadata = lib.substring 0 10 (builtins.hashString "sha256" (crateName + "-" + crateVersion + "___" + toString crateFeatures + "___" + depsMetadata ));
+    # Seed the symbol hashes with something unique every time.
+    # https://doc.rust-lang.org/1.0.0/rustc/metadata/loader/index.html#frobbing-symbols
+    metadata = let
+      depsMetadata = lib.foldl' (str: dep: str + dep.metadata) "" (dependencies ++ buildDependencies);
+      hashedMetadata = builtins.hashString "sha256"
+        (crateName + "-" + crateVersion + "___" + toString crateFeatures + "___" + depsMetadata);
+      in lib.substring 0 10 hashedMetadata;
 
     crateBin = if crate ? crateBin then
        lib.foldl' (bins: bin: let