1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 06:53:54 +02:00

Merge pull request #11115 from NixOS/doc-derivation

Document builtins.derivation
This commit is contained in:
John Ericson 2024-07-25 00:21:53 -04:00 committed by GitHub
commit 90f7f2139e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 67 additions and 15 deletions

View file

@ -50,11 +50,25 @@ set +x
badDiff=0
badExitCode=0
# Extra post-processing that's specific to each test case
postprocess() {
if [[ -e "lang/$1.postprocess" ]]; then
(
# We could allow arbitrary interpreters in .postprocess, but that
# just exposes us to the complexity of not having /usr/bin/env in
# the sandbox. So let's just hardcode bash for now.
set -x;
bash "lang/$1.postprocess" "lang/$1"
)
fi
}
for i in lang/parse-fail-*.nix; do
echo "parsing $i (should fail)";
i=$(basename "$i" .nix)
if expectStderr 1 nix-instantiate --parse - < "lang/$i.nix" > "lang/$i.err"
then
postprocess "$i"
diffAndAccept "$i" err err.exp
else
echo "FAIL: $i shouldn't parse"
@ -71,6 +85,7 @@ for i in lang/parse-okay-*.nix; do
2> "lang/$i.err"
then
sed "s!$(pwd)!/pwd!g" "lang/$i.out" "lang/$i.err"
postprocess "$i"
diffAndAccept "$i" out exp
diffAndAccept "$i" err err.exp
else
@ -94,6 +109,7 @@ for i in lang/eval-fail-*.nix; do
expectStderr 1 nix-instantiate $flags "lang/$i.nix" \
| sed "s!$(pwd)!/pwd!g" > "lang/$i.err"
then
postprocess "$i"
diffAndAccept "$i" err err.exp
else
echo "FAIL: $i shouldn't evaluate"
@ -109,6 +125,7 @@ for i in lang/eval-okay-*.nix; do
if expect 0 nix-instantiate --eval --xml --no-location --strict \
"lang/$i.nix" > "lang/$i.out.xml"
then
postprocess "$i"
diffAndAccept "$i" out.xml exp.xml
else
echo "FAIL: $i should evaluate"
@ -129,6 +146,7 @@ for i in lang/eval-okay-*.nix; do
2> "lang/$i.err"
then
sed -i "s!$(pwd)!/pwd!g" "lang/$i.out" "lang/$i.err"
postprocess "$i"
diffAndAccept "$i" out exp
diffAndAccept "$i" err err.exp
else

View file

@ -1,26 +1,26 @@
error:
… while evaluating the attribute 'outPath'
at <nix/derivation-internal.nix>:19:9:
18| value = commonAttrs // {
19| outPath = builtins.getAttr outputName strict;
at <nix/derivation-internal.nix>:<number>:<number>:
<number>| value = commonAttrs // {
<number>| outPath = builtins.getAttr outputName strict;
| ^
20| drvPath = strict.drvPath;
<number>| drvPath = strict.drvPath;
… while calling the 'getAttr' builtin
at <nix/derivation-internal.nix>:19:19:
18| value = commonAttrs // {
19| outPath = builtins.getAttr outputName strict;
at <nix/derivation-internal.nix>:<number>:<number>:
<number>| value = commonAttrs // {
<number>| outPath = builtins.getAttr outputName strict;
| ^
20| drvPath = strict.drvPath;
<number>| drvPath = strict.drvPath;
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:9:12:
8|
9| strict = derivationStrict drvAttrs;
at <nix/derivation-internal.nix>:<number>:<number>:
<number>|
<number>| strict = derivationStrict drvAttrs;
| ^
10|
<number>|
… while evaluating derivation '~jiggle~'
whose name attribute is located at /pwd/lang/eval-fail-derivation-name.nix:2:3
whose name attribute is located at /pwd/lang/eval-fail-derivation-name.nix:<number>:<number>
error: invalid derivation name: name '~jiggle~' contains illegal character '~'. Please pass a different 'name'.

View file

@ -0,0 +1,9 @@
# shellcheck shell=bash
set -euo pipefail
testcaseBasename=$1
# Line numbers change when derivation.nix docs are updated.
sed -i "$testcaseBasename.err" \
-e 's/[0-9 ][0-9 ][0-9 ][0-9 ][0-9 ][0-9 ][0-9 ][0-9]\([^0-9]\)/<number>\1/g' \
-e 's/[0-9][0-9]*/<number>/g' \
;