|
| 1 | +diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix |
| 2 | +index 30f13b988c6a..2fc608278c07 100644 |
| 3 | +--- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix |
| 4 | ++++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix |
| 5 | +@@ -143,7 +143,11 @@ in |
| 6 | + export CARGO_PKG_AUTHORS="${authors}" |
| 7 | + export CARGO_PKG_DESCRIPTION="${crateDescription}" |
| 8 | + |
| 9 | +- export CARGO_CFG_TARGET_ARCH=${stdenv.hostPlatform.rust.platform.arch} |
| 10 | ++ export CARGO_CFG_TARGET_ARCH=${ |
| 11 | ++ builtins.trace ( |
| 12 | ++ "\nVALUE IS::: " + stdenv.hostPlatform.rust.platform.arch |
| 13 | ++ ) stdenv.hostPlatform.rust.platform.arch |
| 14 | ++ } |
| 15 | + export CARGO_CFG_TARGET_OS=${stdenv.hostPlatform.rust.platform.os} |
| 16 | + export CARGO_CFG_TARGET_FAMILY="unix" |
| 17 | + export CARGO_CFG_UNIX=1 |
| 18 | +diff --git a/pkgs/build-support/rust/build-rust-package/default.nix b/pkgs/build-support/rust/build-rust-package/default.nix |
| 19 | +index 2d215a4eb010..1260494a744f 100644 |
| 20 | +--- a/pkgs/build-support/rust/build-rust-package/default.nix |
| 21 | ++++ b/pkgs/build-support/rust/build-rust-package/default.nix |
| 22 | +@@ -14,6 +14,7 @@ |
| 23 | + rustc, |
| 24 | + libiconv, |
| 25 | + windows, |
| 26 | ++ rustConfig, |
| 27 | + }: |
| 28 | + |
| 29 | + lib.extendMkDerivation { |
| 30 | +@@ -28,6 +29,7 @@ lib.extendMkDerivation { |
| 31 | + extendDrvArgs = |
| 32 | + finalAttrs: |
| 33 | + { |
| 34 | ++ RUSTFLAGS ? (rustConfig.RUSTFLAGS or ""), |
| 35 | + name ? "${args.pname}-${args.version}", |
| 36 | + |
| 37 | + # Name for the vendored dependencies tarball |
| 38 | +@@ -74,98 +76,103 @@ lib.extendMkDerivation { |
| 39 | + assert lib.assertMsg useFetchCargoVendor |
| 40 | + "buildRustPackage: `useFetchCargoVendor` is non‐optional and enabled by default as of 25.05"; |
| 41 | + |
| 42 | +- lib.optionalAttrs (stdenv.hostPlatform.isDarwin && buildType == "debug") { |
| 43 | +- RUSTFLAGS = "-C split-debuginfo=packed " + (args.RUSTFLAGS or ""); |
| 44 | +- } |
| 45 | +- // { |
| 46 | +- cargoDeps = |
| 47 | +- if cargoVendorDir != null then |
| 48 | +- null |
| 49 | +- else if cargoDeps != null then |
| 50 | +- cargoDeps |
| 51 | +- else if cargoLock != null then |
| 52 | +- importCargoLock cargoLock |
| 53 | +- else if args.cargoHash or null == null then |
| 54 | +- throw "cargoHash, cargoVendorDir, cargoDeps, or cargoLock must be set" |
| 55 | +- else |
| 56 | +- fetchCargoVendor ( |
| 57 | +- { |
| 58 | +- inherit |
| 59 | +- src |
| 60 | +- srcs |
| 61 | +- sourceRoot |
| 62 | +- cargoRoot |
| 63 | +- preUnpack |
| 64 | +- unpackPhase |
| 65 | +- postUnpack |
| 66 | +- ; |
| 67 | +- name = cargoDepsName; |
| 68 | +- patches = cargoPatches; |
| 69 | +- hash = args.cargoHash; |
| 70 | +- } |
| 71 | +- // depsExtraArgs |
| 72 | +- ); |
| 73 | +- inherit buildAndTestSubdir; |
| 74 | +- |
| 75 | +- cargoBuildType = buildType; |
| 76 | +- |
| 77 | +- cargoCheckType = checkType; |
| 78 | +- |
| 79 | +- cargoBuildNoDefaultFeatures = buildNoDefaultFeatures; |
| 80 | +- |
| 81 | +- cargoCheckNoDefaultFeatures = checkNoDefaultFeatures; |
| 82 | +- |
| 83 | +- cargoBuildFeatures = buildFeatures; |
| 84 | +- |
| 85 | +- cargoCheckFeatures = checkFeatures; |
| 86 | +- |
| 87 | +- nativeBuildInputs = |
| 88 | +- nativeBuildInputs |
| 89 | +- ++ lib.optionals auditable [ |
| 90 | +- (buildPackages.cargo-auditable-cargo-wrapper.override { |
| 91 | +- inherit cargo cargo-auditable; |
| 92 | +- }) |
| 93 | +- ] |
| 94 | +- ++ [ |
| 95 | +- cargoBuildHook |
| 96 | +- (if useNextest then cargoNextestHook else cargoCheckHook) |
| 97 | +- cargoInstallHook |
| 98 | +- cargoSetupHook |
| 99 | +- rustc |
| 100 | +- cargo |
| 101 | +- ]; |
| 102 | +- |
| 103 | +- buildInputs = |
| 104 | +- buildInputs |
| 105 | +- ++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ] |
| 106 | +- ++ lib.optionals stdenv.hostPlatform.isMinGW [ windows.pthreads ]; |
| 107 | +- |
| 108 | +- patches = cargoPatches ++ patches; |
| 109 | +- |
| 110 | +- PKG_CONFIG_ALLOW_CROSS = if stdenv.buildPlatform != stdenv.hostPlatform then 1 else 0; |
| 111 | +- |
| 112 | +- postUnpack = |
| 113 | +- '' |
| 114 | +- eval "$cargoDepsHook" |
| 115 | +- |
| 116 | +- export RUST_LOG=${logLevel} |
| 117 | +- '' |
| 118 | +- + (args.postUnpack or ""); |
| 119 | +- |
| 120 | +- configurePhase = |
| 121 | +- args.configurePhase or '' |
| 122 | +- runHook preConfigure |
| 123 | +- runHook postConfigure |
| 124 | +- ''; |
| 125 | +- |
| 126 | +- doCheck = args.doCheck or true; |
| 127 | +- |
| 128 | +- strictDeps = true; |
| 129 | +- |
| 130 | +- meta = meta // { |
| 131 | +- badPlatforms = meta.badPlatforms or [ ] ++ rustc.badTargetPlatforms; |
| 132 | +- # default to Rust's platforms |
| 133 | +- platforms = lib.intersectLists meta.platforms or lib.platforms.all rustc.targetPlatforms; |
| 134 | ++ if (stdenv.hostPlatform.isDarwin && buildType == "debug") then |
| 135 | ++ { |
| 136 | ++ RUSTFLAGS = "-C split-debuginfo=packed " + (args.RUSTFLAGS or ""); |
| 137 | ++ } |
| 138 | ++ else |
| 139 | ++ { |
| 140 | ++ RUSTFLAGS = (args.RUSTFLAGS or ""); |
| 141 | ++ } |
| 142 | ++ // { |
| 143 | ++ cargoDeps = |
| 144 | ++ if cargoVendorDir != null then |
| 145 | ++ null |
| 146 | ++ else if cargoDeps != null then |
| 147 | ++ cargoDeps |
| 148 | ++ else if cargoLock != null then |
| 149 | ++ importCargoLock cargoLock |
| 150 | ++ else if args.cargoHash or null == null then |
| 151 | ++ throw "cargoHash, cargoVendorDir, cargoDeps, or cargoLock must be set" |
| 152 | ++ else |
| 153 | ++ fetchCargoVendor ( |
| 154 | ++ { |
| 155 | ++ inherit |
| 156 | ++ src |
| 157 | ++ srcs |
| 158 | ++ sourceRoot |
| 159 | ++ cargoRoot |
| 160 | ++ preUnpack |
| 161 | ++ unpackPhase |
| 162 | ++ postUnpack |
| 163 | ++ ; |
| 164 | ++ name = cargoDepsName; |
| 165 | ++ patches = cargoPatches; |
| 166 | ++ hash = args.cargoHash; |
| 167 | ++ } |
| 168 | ++ // depsExtraArgs |
| 169 | ++ ); |
| 170 | ++ inherit buildAndTestSubdir; |
| 171 | ++ |
| 172 | ++ cargoBuildType = buildType; |
| 173 | ++ |
| 174 | ++ cargoCheckType = checkType; |
| 175 | ++ |
| 176 | ++ cargoBuildNoDefaultFeatures = buildNoDefaultFeatures; |
| 177 | ++ |
| 178 | ++ cargoCheckNoDefaultFeatures = checkNoDefaultFeatures; |
| 179 | ++ |
| 180 | ++ cargoBuildFeatures = buildFeatures; |
| 181 | ++ |
| 182 | ++ cargoCheckFeatures = checkFeatures; |
| 183 | ++ |
| 184 | ++ nativeBuildInputs = |
| 185 | ++ nativeBuildInputs |
| 186 | ++ ++ lib.optionals auditable [ |
| 187 | ++ (buildPackages.cargo-auditable-cargo-wrapper.override { |
| 188 | ++ inherit cargo cargo-auditable; |
| 189 | ++ }) |
| 190 | ++ ] |
| 191 | ++ ++ [ |
| 192 | ++ cargoBuildHook |
| 193 | ++ (if useNextest then cargoNextestHook else cargoCheckHook) |
| 194 | ++ cargoInstallHook |
| 195 | ++ cargoSetupHook |
| 196 | ++ rustc |
| 197 | ++ cargo |
| 198 | ++ ]; |
| 199 | ++ |
| 200 | ++ buildInputs = |
| 201 | ++ buildInputs |
| 202 | ++ ++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ] |
| 203 | ++ ++ lib.optionals stdenv.hostPlatform.isMinGW [ windows.pthreads ]; |
| 204 | ++ |
| 205 | ++ patches = cargoPatches ++ patches; |
| 206 | ++ |
| 207 | ++ PKG_CONFIG_ALLOW_CROSS = if stdenv.buildPlatform != stdenv.hostPlatform then 1 else 0; |
| 208 | ++ |
| 209 | ++ postUnpack = |
| 210 | ++ '' |
| 211 | ++ eval "$cargoDepsHook" |
| 212 | ++ |
| 213 | ++ export RUST_LOG=${logLevel} |
| 214 | ++ '' |
| 215 | ++ + (args.postUnpack or ""); |
| 216 | ++ |
| 217 | ++ configurePhase = |
| 218 | ++ args.configurePhase or '' |
| 219 | ++ runHook preConfigure |
| 220 | ++ runHook postConfigure |
| 221 | ++ ''; |
| 222 | ++ |
| 223 | ++ doCheck = args.doCheck or true; |
| 224 | ++ |
| 225 | ++ strictDeps = true; |
| 226 | ++ |
| 227 | ++ meta = meta // { |
| 228 | ++ badPlatforms = meta.badPlatforms or [ ] ++ rustc.badTargetPlatforms; |
| 229 | ++ # default to Rust's platforms |
| 230 | ++ platforms = lib.intersectLists meta.platforms or lib.platforms.all rustc.targetPlatforms; |
| 231 | ++ }; |
| 232 | + }; |
| 233 | +- }; |
| 234 | + } |
| 235 | +diff --git a/pkgs/development/compilers/rust/make-rust-platform.nix b/pkgs/development/compilers/rust/make-rust-platform.nix |
| 236 | +index 03564bc068f7..1b1286aad70e 100644 |
| 237 | +--- a/pkgs/development/compilers/rust/make-rust-platform.nix |
| 238 | ++++ b/pkgs/development/compilers/rust/make-rust-platform.nix |
| 239 | +@@ -8,6 +8,7 @@ |
| 240 | + runCommand, |
| 241 | + generateSplicesForMkScope, |
| 242 | + makeScopeWithSplicing', |
| 243 | ++ rustConfig ? { }, |
| 244 | + }@prev: |
| 245 | + |
| 246 | + { |
| 247 | +@@ -30,14 +31,17 @@ |
| 248 | + inherit cargo; |
| 249 | + }; |
| 250 | + |
| 251 | +- buildRustPackage = callPackage ../../../build-support/rust/build-rust-package { |
| 252 | +- inherit |
| 253 | +- stdenv |
| 254 | +- rustc |
| 255 | +- cargo |
| 256 | +- cargo-auditable |
| 257 | +- ; |
| 258 | +- }; |
| 259 | ++ buildRustPackage = ( |
| 260 | ++ callPackage ../../../build-support/rust/build-rust-package { |
| 261 | ++ inherit |
| 262 | ++ stdenv |
| 263 | ++ rustc |
| 264 | ++ cargo |
| 265 | ++ cargo-auditable |
| 266 | ++ rustConfig |
| 267 | ++ ; |
| 268 | ++ } |
| 269 | ++ ); |
| 270 | + |
| 271 | + importCargoLock = buildPackages.callPackage ../../../build-support/rust/import-cargo-lock.nix { |
| 272 | + inherit cargo; |
0 commit comments