Merge staging-next into staging

authored by github-actions[bot] and committed by GitHub c020c1ab 6d01ee43

+16 -21
+2 -7
pkgs/build-support/rust/build-rust-package/default.nix
··· 82 82 targetIsJSON = lib.hasSuffix ".json" target; 83 83 useSysroot = targetIsJSON && !__internal_dontAddSysroot; 84 84 85 - # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168 86 - # the "${}" is needed to transform the path into a /nix/store path before baseNameOf 87 - shortTarget = if targetIsJSON then 88 - (lib.removeSuffix ".json" (builtins.baseNameOf "${target}")) 89 - else target; 90 - 91 85 sysroot = callPackage ./sysroot { } { 92 - inherit target shortTarget; 86 + inherit target; 87 + shortTarget = rust.lib.toRustTargetSpecShort stdenv.hostPlatform; 93 88 RUSTFLAGS = args.RUSTFLAGS or ""; 94 89 originalCargoToml = src + /Cargo.toml; # profile info is later extracted 95 90 };
+4 -13
pkgs/build-support/rust/hooks/default.nix
··· 12 12 13 13 # This confusingly-named parameter indicates the *subdirectory of 14 14 # `target/` from which to copy the build artifacts. It is derived 15 - # from a stdenv platform (or a JSON file; see below). 16 - , target ? rust.toRustTargetSpec stdenv.hostPlatform 15 + # from a stdenv platform (or a JSON file). 16 + , target ? rust.lib.toRustTargetSpecShort stdenv.hostPlatform 17 17 }: 18 18 19 - let 20 - targetIsJSON = lib.hasSuffix ".json" target; 21 - 22 - # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168 23 - # the "${}" is needed to transform the path into a /nix/store path before baseNameOf 24 - targetSubdirectory = if targetIsJSON then 25 - (lib.removeSuffix ".json" (builtins.baseNameOf "${target}")) 26 - else target; 27 - 28 - in { 19 + { 29 20 cargoBuildHook = callPackage ({ }: 30 21 makeSetupHook { 31 22 name = "cargo-build-hook.sh"; ··· 49 40 name = "cargo-install-hook.sh"; 50 41 propagatedBuildInputs = [ ]; 51 42 substitutions = { 52 - inherit targetSubdirectory; 43 + targetSubdirectory = target; 53 44 }; 54 45 } ./cargo-install-hook.sh) {}; 55 46
+10 -1
pkgs/build-support/rust/lib/default.nix
··· 63 63 then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform) 64 64 else toRustTarget platform; 65 65 66 + # Returns the name of the rust target if it is standard, or the 67 + # basename of the file containing the custom target spec, without 68 + # the .json extension. 69 + # 70 + # This is the name used by Cargo for target subdirectories. 71 + toRustTargetSpecShort = platform: 72 + lib.removeSuffix ".json" 73 + (baseNameOf "${toRustTargetSpec platform}"); 74 + 66 75 # When used as part of an environment variable name, triples are 67 76 # uppercased and have all hyphens replaced by underscores: 68 77 # ··· 72 81 toRustTargetForUseInEnvVars = platform: 73 82 lib.strings.replaceStrings ["-"] ["_"] 74 83 (lib.strings.toUpper 75 - (toRustTarget platform)); 84 + (toRustTargetSpecShort platform)); 76 85 77 86 # Returns true if the target is no_std 78 87 # https://github.com/rust-lang/rust/blob/2e44c17c12cec45b6a682b1e53a04ac5b5fcc9d2/src/bootstrap/config.rs#L415-L421