···8282 targetIsJSON = lib.hasSuffix ".json" target;
8383 useSysroot = targetIsJSON && !__internal_dontAddSysroot;
84848585- # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168
8686- # the "${}" is needed to transform the path into a /nix/store path before baseNameOf
8787- shortTarget = if targetIsJSON then
8888- (lib.removeSuffix ".json" (builtins.baseNameOf "${target}"))
8989- else target;
9090-9185 sysroot = callPackage ./sysroot { } {
9292- inherit target shortTarget;
8686+ inherit target;
8787+ shortTarget = rust.lib.toRustTargetSpecShort stdenv.hostPlatform;
9388 RUSTFLAGS = args.RUSTFLAGS or "";
9489 originalCargoToml = src + /Cargo.toml; # profile info is later extracted
9590 };
+4-13
pkgs/build-support/rust/hooks/default.nix
···12121313# This confusingly-named parameter indicates the *subdirectory of
1414# `target/` from which to copy the build artifacts. It is derived
1515-# from a stdenv platform (or a JSON file; see below).
1616-, target ? rust.toRustTargetSpec stdenv.hostPlatform
1515+# from a stdenv platform (or a JSON file).
1616+, target ? rust.lib.toRustTargetSpecShort stdenv.hostPlatform
1717}:
18181919-let
2020- targetIsJSON = lib.hasSuffix ".json" target;
2121-2222- # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168
2323- # the "${}" is needed to transform the path into a /nix/store path before baseNameOf
2424- targetSubdirectory = if targetIsJSON then
2525- (lib.removeSuffix ".json" (builtins.baseNameOf "${target}"))
2626- else target;
2727-2828-in {
1919+{
2920 cargoBuildHook = callPackage ({ }:
3021 makeSetupHook {
3122 name = "cargo-build-hook.sh";
···4940 name = "cargo-install-hook.sh";
5041 propagatedBuildInputs = [ ];
5142 substitutions = {
5252- inherit targetSubdirectory;
4343+ targetSubdirectory = target;
5344 };
5445 } ./cargo-install-hook.sh) {};
5546
+10-1
pkgs/build-support/rust/lib/default.nix
···6363 then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform)
6464 else toRustTarget platform;
65656666+ # Returns the name of the rust target if it is standard, or the
6767+ # basename of the file containing the custom target spec, without
6868+ # the .json extension.
6969+ #
7070+ # This is the name used by Cargo for target subdirectories.
7171+ toRustTargetSpecShort = platform:
7272+ lib.removeSuffix ".json"
7373+ (baseNameOf "${toRustTargetSpec platform}");
7474+6675 # When used as part of an environment variable name, triples are
6776 # uppercased and have all hyphens replaced by underscores:
6877 #
···7281 toRustTargetForUseInEnvVars = platform:
7382 lib.strings.replaceStrings ["-"] ["_"]
7483 (lib.strings.toUpper
7575- (toRustTarget platform));
8484+ (toRustTargetSpecShort platform));
76857786 # Returns true if the target is no_std
7887 # https://github.com/rust-lang/rust/blob/2e44c17c12cec45b6a682b1e53a04ac5b5fcc9d2/src/bootstrap/config.rs#L415-L421