diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index ddf2fce3cae..87115e392da 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -11,14 +11,6 @@ let sha256 = depsSha256; }; - # The following is the directory name cargo creates when the registry index - # URL is file:///dev/null - # - # It's OK to use /dev/null as the URL because by the time we do this, cargo - # won't attempt to update the registry anymore, so the URL is more or less - # irrelevant - registryIndexDirName = "-ba82b75dd6681d6f"; - in stdenv.mkDerivation (args // { inherit cargoDeps rustRegistry; @@ -34,18 +26,34 @@ in stdenv.mkDerivation (args // { cp -r "$cargoDeps" deps chmod +w deps -R + # It's OK to use /dev/null as the URL because by the time we do this, cargo + # won't attempt to update the registry anymore, so the URL is more or less + # irrelevant + cat < deps/config [registry] index = "file:///dev/null" EOF - echo "Using rust registry from $rustRegistry" - - ln -s "$rustRegistry" "deps/registry/index/${registryIndexDirName}" - export CARGO_HOME="$(realpath deps)" + # Let's find out which $indexHash cargo uses for file:///dev/null + (cd $sourceRoot && cargo fetch &>/dev/null) + cd deps + indexHash="$(basename $(echo registry/index/*))" + + echo "Using indexHash '$indexHash'" + + rm -rf -- "registry/cache/$indexHash" \ + "registry/index/$indexHash" + + mv registry/cache/HASH "registry/cache/$indexHash" + + echo "Using rust registry from $rustRegistry" + ln -s "$rustRegistry" "registry/index/$indexHash" + # Retrieved the Cargo.lock file which we saved during the fetch + cd .. mv deps/Cargo.lock $sourceRoot/ ( diff --git a/pkgs/build-support/rust/fetch-cargo-deps b/pkgs/build-support/rust/fetch-cargo-deps index c7799fb1b1f..69eb404e644 100755 --- a/pkgs/build-support/rust/fetch-cargo-deps +++ b/pkgs/build-support/rust/fetch-cargo-deps @@ -104,12 +104,9 @@ substituteInPlace Cargo.lock \ set -u mv Cargo.lock $out/ -# The following is the $indexHash cargo uses for the registry index when -# its URL is file:///dev/null, which is the registry index URL we use to make -# sure our output is deterministic. -registryIndexDirName="-ba82b75dd6681d6f" -mv $out/registry/cache/* $out/registry/cache/$registryIndexDirName +# Let's replace $indexHash with something more deterministic +mv $out/registry/cache/* $out/registry/cache/HASH # The registry index changes all the time, so it's not deterministic # We'll symlink it before running 'cargo build' diff --git a/pkgs/development/tools/build-managers/cargo/default.nix b/pkgs/development/tools/build-managers/cargo/default.nix index 3ac6e1c3e94..e7a45f1c348 100644 --- a/pkgs/development/tools/build-managers/cargo/default.nix +++ b/pkgs/development/tools/build-managers/cargo/default.nix @@ -15,7 +15,7 @@ buildRustPackage rec { leaveDotGit = true; }; - depsSha256 = "0s9f00kg7q9dxd8g98k3z4qv404p9ra73l1bzxs6qzk54qhg44dp"; + depsSha256 = "1b0mpdxmp7inkg59n2phjwzpz5gx22wqg9rfd1s01a5ylara37jw"; buildInputs = [ file curl pkgconfig python openssl cmake zlib ]; diff --git a/pkgs/development/tools/rust/racer/default.nix b/pkgs/development/tools/rust/racer/default.nix index 61fe2238a77..0b614f4edc6 100644 --- a/pkgs/development/tools/rust/racer/default.nix +++ b/pkgs/development/tools/rust/racer/default.nix @@ -11,7 +11,7 @@ buildRustPackage rec { sha256 = "0g420cbqpknhl61a4mpk3bbia8agf657d9vzzcqr338lmni80qz7"; }; - depsSha256 = "1wmpd2cjmk59382dq59hmb0xa6fxbnmmaz4nfs96qf613r5ylvra"; + depsSha256 = "0s951apqcr96lvc1jamk6qw3631gwnlnfgcx55vlznfm7shnmywn"; buildInputs = [ makeWrapper ];