rustPlatform.fetchCargoTarball: deprecate

+84 -72
+4
doc/release-notes/rl-2505.section.md
··· 8 8 9 9 - `services.rippleDataApi` has been removed, as `ripple-data-api` was broken and had not been updated since 2022. 10 10 11 + - The `rustPlatform.fetchCargoTarball` function is deprecated, because it relied on `cargo vendor` not changing its output format to keep fixed-output derivation hashes the same, which is a Nix invariant, and Cargo 1.84.0 changed `cargo vendor`'s output format. 12 + It should generally be replaced with `rustPlatform.fetchCargoVendor`, but `rustPlatform.importCargoLock` may also be appropriate in some circumstances. 13 + `rustPlatform.buildRustPackage` users must set `useFetchCargoVendor` to `true` and regenerate the `cargoHash`. 14 + 11 15 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> 12 16 13 17 ### Titanium removed {#sec-nixpkgs-release-25.05-incompatibilities-titanium-removed}
+80 -72
pkgs/build-support/rust/fetch-cargo-tarball/default.nix
··· 69 69 else 70 70 throw "fetchCargoTarball requires a hash for ${name}"; 71 71 in 72 - stdenv.mkDerivation ( 73 - { 74 - name = "${name}-vendor.tar.gz"; 75 - nativeBuildInputs = [ 76 - cacert 77 - git 78 - cargo-vendor-normalise 79 - cargo 80 - ] ++ nativeBuildInputs; 72 + lib.warn 73 + '' 74 + rustPlatform.fetchCargoTarball is deprecated in favor of rustPlatform.fetchCargoVendor. 75 + If you are using buildRustPackage, try setting useFetchCargoVendor = true and regenerating cargoHash. 76 + See the 25.05 release notes for more information. 77 + '' 78 + ( 79 + stdenv.mkDerivation ( 80 + { 81 + name = "${name}-vendor.tar.gz"; 82 + nativeBuildInputs = [ 83 + cacert 84 + git 85 + cargo-vendor-normalise 86 + cargo 87 + ] ++ nativeBuildInputs; 81 88 82 - dontConfigure = true; 83 - buildPhase = '' 84 - runHook preBuild 89 + dontConfigure = true; 90 + buildPhase = '' 91 + runHook preBuild 85 92 86 - # Ensure deterministic Cargo vendor builds 87 - export SOURCE_DATE_EPOCH=1 93 + # Ensure deterministic Cargo vendor builds 94 + export SOURCE_DATE_EPOCH=1 88 95 89 - if [ -n "''${cargoRoot-}" ]; then 90 - cd "$cargoRoot" 91 - fi 96 + if [ -n "''${cargoRoot-}" ]; then 97 + cd "$cargoRoot" 98 + fi 92 99 93 - if [[ ! -f Cargo.lock ]]; then 94 - echo 95 - echo "ERROR: The Cargo.lock file doesn't exist" 96 - echo 97 - echo "Cargo.lock is needed to make sure that cargoHash/cargoSha256 doesn't change" 98 - echo "when the registry is updated." 99 - echo 100 + if [[ ! -f Cargo.lock ]]; then 101 + echo 102 + echo "ERROR: The Cargo.lock file doesn't exist" 103 + echo 104 + echo "Cargo.lock is needed to make sure that cargoHash/cargoSha256 doesn't change" 105 + echo "when the registry is updated." 106 + echo 100 107 101 - exit 1 102 - fi 108 + exit 1 109 + fi 103 110 104 - # Keep the original around for copyLockfile 105 - cp Cargo.lock Cargo.lock.orig 111 + # Keep the original around for copyLockfile 112 + cp Cargo.lock Cargo.lock.orig 106 113 107 - export CARGO_HOME=$(mktemp -d cargo-home.XXX) 108 - CARGO_CONFIG=$(mktemp cargo-config.XXXX) 114 + export CARGO_HOME=$(mktemp -d cargo-home.XXX) 115 + CARGO_CONFIG=$(mktemp cargo-config.XXXX) 109 116 110 - if [[ -n "$NIX_CRATES_INDEX" ]]; then 111 - cat >$CARGO_HOME/config.toml <<EOF 112 - [source.crates-io] 113 - replace-with = 'mirror' 114 - [source.mirror] 115 - registry = "$NIX_CRATES_INDEX" 116 - EOF 117 - fi 117 + if [[ -n "$NIX_CRATES_INDEX" ]]; then 118 + cat >$CARGO_HOME/config.toml <<EOF 119 + [source.crates-io] 120 + replace-with = 'mirror' 121 + [source.mirror] 122 + registry = "$NIX_CRATES_INDEX" 123 + EOF 124 + fi 118 125 119 - ${cargoUpdateHook} 126 + ${cargoUpdateHook} 120 127 121 - # Override the `http.cainfo` option usually specified in `.cargo/config`. 122 - export CARGO_HTTP_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt 128 + # Override the `http.cainfo` option usually specified in `.cargo/config`. 129 + export CARGO_HTTP_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt 123 130 124 - if grep '^source = "git' Cargo.lock; then 125 - echo 126 - echo "ERROR: The Cargo.lock contains git dependencies" 127 - echo 128 - echo "This is not supported in the default fixed-output derivation fetcher." 129 - echo "Set \`useFetchCargoVendor = true\` / use fetchCargoVendor" 130 - echo "or use cargoLock.lockFile / importCargoLock instead." 131 - echo 131 + if grep '^source = "git' Cargo.lock; then 132 + echo 133 + echo "ERROR: The Cargo.lock contains git dependencies" 134 + echo 135 + echo "This is not supported in the default fixed-output derivation fetcher." 136 + echo "Set \`useFetchCargoVendor = true\` / use fetchCargoVendor" 137 + echo "or use cargoLock.lockFile / importCargoLock instead." 138 + echo 132 139 133 - exit 1 134 - fi 140 + exit 1 141 + fi 135 142 136 - cargo vendor $name --respect-source-config | cargo-vendor-normalise > $CARGO_CONFIG 143 + cargo vendor $name --respect-source-config | cargo-vendor-normalise > $CARGO_CONFIG 137 144 138 - # Create an empty vendor directory when there is no dependency to vendor 139 - mkdir -p $name 140 - # Add the Cargo.lock to allow hash invalidation 141 - cp Cargo.lock.orig $name/Cargo.lock 145 + # Create an empty vendor directory when there is no dependency to vendor 146 + mkdir -p $name 147 + # Add the Cargo.lock to allow hash invalidation 148 + cp Cargo.lock.orig $name/Cargo.lock 142 149 143 - # Packages with git dependencies generate non-default cargo configs, so 144 - # always install it rather than trying to write a standard default template. 145 - install -D $CARGO_CONFIG $name/.cargo/config 150 + # Packages with git dependencies generate non-default cargo configs, so 151 + # always install it rather than trying to write a standard default template. 152 + install -D $CARGO_CONFIG $name/.cargo/config 146 153 147 - runHook postBuild 148 - ''; 154 + runHook postBuild 155 + ''; 149 156 150 - # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ 151 - installPhase = '' 152 - tar --owner=0 --group=0 --numeric-owner --format=gnu \ 153 - --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ 154 - -czf $out $name 155 - ''; 157 + # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ 158 + installPhase = '' 159 + tar --owner=0 --group=0 --numeric-owner --format=gnu \ 160 + --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ 161 + -czf $out $name 162 + ''; 156 163 157 - inherit (hash_) outputHashAlgo outputHash; 164 + inherit (hash_) outputHashAlgo outputHash; 158 165 159 - impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "NIX_CRATES_INDEX" ]; 160 - } 161 - // (removeAttrs args removedArgs) 162 - ) 166 + impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "NIX_CRATES_INDEX" ]; 167 + } 168 + // (removeAttrs args removedArgs) 169 + ) 170 + )