1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

Merge pull request #13980 from obsidiansystems/drv-json-issue-13570

Make the JSON format for derivation use basename store paths
This commit is contained in:
Robert Hensing 2025-09-17 23:31:41 +02:00 committed by GitHub
commit b4fcb64276
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 275 additions and 140 deletions

View file

@ -62,12 +62,15 @@ builtins.outputOf
"hashAlgo": "sha256"
}
},
"system": "${system}"
"system": "${system}",
"version": 3
}
EOF
drvs[$word]="$(echo "$json" | nix derivation add)"
drvPath=$(echo "$json" | nix derivation add)
storeDir=$(dirname "$drvPath")
drvs[$word]="$(basename "$drvPath")"
done
cp "''${drvs[e]}" $out
cp "''${storeDir}/''${drvs[e]}" $out
'';
__contentAddressed = true;

View file

@ -50,8 +50,8 @@ path4=$(nix build -L --no-link --json --file ./impure-derivations.nix impureOnIm
(! nix build -L --no-link --json --file ./impure-derivations.nix inputAddressed 2>&1) | grep 'depends on impure derivation'
drvPath=$(nix eval --json --file ./impure-derivations.nix impure.drvPath | jq -r .)
[[ $(nix derivation show $drvPath | jq ".[\"$drvPath\"].outputs.out.impure") = true ]]
[[ $(nix derivation show $drvPath | jq ".[\"$drvPath\"].outputs.stuff.impure") = true ]]
[[ $(nix derivation show $drvPath | jq ".[\"$(basename "$drvPath")\"].outputs.out.impure") = true ]]
[[ $(nix derivation show $drvPath | jq ".[\"$(basename "$drvPath")\"].outputs.stuff.impure") = true ]]
# Fixed-output derivations *can* depend on impure derivations.
path5=$(nix build -L --no-link --json --file ./impure-derivations.nix contentAddressed | jq -r .[].outputs.out)

View file

@ -50,4 +50,4 @@ expectStderr 0 nix-instantiate --expr "$hackyExpr" --eval --strict | grepQuiet "
# Check it works with the expected structured attrs
hacky=$(nix-instantiate --expr "$hackyExpr")
nix derivation show "$hacky" | jq --exit-status '."'"$hacky"'".structuredAttrs | . == {"a": 1}'
nix derivation show "$hacky" | jq --exit-status '."'"$(basename "$hacky")"'".structuredAttrs | . == {"a": 1}'