From 4f9eda21d97a6881eb35e68ac93095fdb899bca4 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Mon, 23 Mar 2026 17:50:37 +0100 Subject: [PATCH 1/2] rustPlatform.importCargoLock: use structuredAttrs instead of passAsFile --- pkgs/build-support/rust/import-cargo-lock.nix | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/pkgs/build-support/rust/import-cargo-lock.nix b/pkgs/build-support/rust/import-cargo-lock.nix index a3cd9b825ffc..f668cb5bac05 100644 --- a/pkgs/build-support/rust/import-cargo-lock.nix +++ b/pkgs/build-support/rust/import-cargo-lock.nix @@ -263,17 +263,21 @@ let vendorDir = runCommand "cargo-vendor-dir" ( - if lockFile == null then - { - inherit lockFileContents; - passAsFile = [ "lockFileContents" ]; - } - else - { - passthru = { - inherit lockFile; - }; - } + { + __structuredAttrs = true; + } + // ( + if lockFile == null then + { + inherit lockFileContents; + } + else + { + passthru = { + inherit lockFile; + }; + } + ) ) '' mkdir -p $out/.cargo @@ -282,7 +286,9 @@ let if lockFile != null then "ln -s ${lockFile} $out/Cargo.lock" else - "cp $lockFileContentsPath $out/Cargo.lock" + '' + printf "%s" "$lockFileContents" > "$out/Cargo.lock" + '' } cat > $out/.cargo/config.toml < Date: Mon, 23 Mar 2026 17:51:31 +0100 Subject: [PATCH 2/2] rustPlatform.importCargoLock: switch if/else statements Now they are in the same order as the same check above --- pkgs/build-support/rust/import-cargo-lock.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/rust/import-cargo-lock.nix b/pkgs/build-support/rust/import-cargo-lock.nix index f668cb5bac05..9c172c7842f8 100644 --- a/pkgs/build-support/rust/import-cargo-lock.nix +++ b/pkgs/build-support/rust/import-cargo-lock.nix @@ -283,12 +283,12 @@ let mkdir -p $out/.cargo ${ - if lockFile != null then - "ln -s ${lockFile} $out/Cargo.lock" - else + if lockFile == null then '' printf "%s" "$lockFileContents" > "$out/Cargo.lock" '' + else + "ln -s ${lockFile} $out/Cargo.lock" } cat > $out/.cargo/config.toml <