mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Merge branch 'master' into angerman/mac-fix-recursive-nix
This commit is contained in:
commit
381a32981b
229 changed files with 4173 additions and 1916 deletions
|
@ -17,13 +17,13 @@ nix-build build-hook.nix -A passthru.input2 \
|
|||
--store "$TEST_ROOT/local" \
|
||||
--option system-features bar
|
||||
|
||||
# Now when we go to build that downstream derivation, Nix will fail
|
||||
# because we cannot trustlessly build input-addressed derivations with
|
||||
# `inputDrv` dependencies.
|
||||
# Now when we go to build that downstream derivation, Nix will try to
|
||||
# copy our already-build `input2` to the remote store. That store object
|
||||
# is input-addressed, so this will fail.
|
||||
|
||||
file=build-hook.nix
|
||||
prog=$(readlink -e ./nix-daemon-untrusting.sh)
|
||||
proto=ssh-ng
|
||||
|
||||
expectStderr 1 source build-remote-trustless.sh \
|
||||
| grepQuiet "you are not privileged to build input-addressed derivations"
|
||||
| grepQuiet "cannot add path '[^ ]*' because it lacks a signature by a trusted key"
|
||||
|
|
13
tests/build-remote-trustless-should-pass-2.sh
Normal file
13
tests/build-remote-trustless-should-pass-2.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
source common.sh
|
||||
|
||||
enableFeatures "daemon-trust-override"
|
||||
|
||||
restartDaemon
|
||||
|
||||
# Remote doesn't trust us
|
||||
file=build-hook.nix
|
||||
prog=$(readlink -e ./nix-daemon-untrusting.sh)
|
||||
proto=ssh-ng
|
||||
|
||||
source build-remote-trustless.sh
|
||||
source build-remote-trustless-after.sh
|
|
@ -57,6 +57,30 @@ nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
|
|||
(.outputs | keys == ["a_a", "b", "c"]))
|
||||
'
|
||||
|
||||
# test buidling from non-drv attr path
|
||||
|
||||
nix build -f multiple-outputs.nix --json 'e.a_a.outPath' --no-link | jq --exit-status '
|
||||
(.[0] |
|
||||
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
||||
(.outputs | keys == ["a_a"]))
|
||||
'
|
||||
|
||||
# Illegal type of string context
|
||||
expectStderr 1 nix build -f multiple-outputs.nix 'e.a_a.drvPath' \
|
||||
| grepQuiet "has a context which refers to a complete source and binary closure."
|
||||
|
||||
# No string context
|
||||
expectStderr 1 nix build --expr '""' --no-link \
|
||||
| grepQuiet "has 0 entries in its context. It should only have exactly one entry"
|
||||
|
||||
# Too much string context
|
||||
expectStderr 1 nix build --impure --expr 'with (import ./multiple-outputs.nix).e.a_a; "${drvPath}${outPath}"' --no-link \
|
||||
| grepQuiet "has 2 entries in its context. It should only have exactly one entry"
|
||||
|
||||
nix build --impure --json --expr 'builtins.unsafeDiscardOutputDependency (import ./multiple-outputs.nix).e.a_a.drvPath' --no-link | jq --exit-status '
|
||||
(.[0] | .path | match(".*multiple-outputs-e.drv"))
|
||||
'
|
||||
|
||||
# Test building from raw store path to drv not expression.
|
||||
|
||||
drv=$(nix eval -f multiple-outputs.nix --raw a.drvPath)
|
||||
|
|
8
tests/dyn-drv/common.sh
Normal file
8
tests/dyn-drv/common.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
source ../common.sh
|
||||
|
||||
# Need backend to support text-hashing too
|
||||
requireDaemonNewerThan "2.16.0pre20230419"
|
||||
|
||||
enableFeatures "ca-derivations dynamic-derivations"
|
||||
|
||||
restartDaemon
|
1
tests/dyn-drv/config.nix.in
Symbolic link
1
tests/dyn-drv/config.nix.in
Symbolic link
|
@ -0,0 +1 @@
|
|||
../config.nix.in
|
33
tests/dyn-drv/recursive-mod-json.nix
Normal file
33
tests/dyn-drv/recursive-mod-json.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
with import ./config.nix;
|
||||
|
||||
let innerName = "foo"; in
|
||||
|
||||
mkDerivation rec {
|
||||
name = "${innerName}.drv";
|
||||
SHELL = shell;
|
||||
|
||||
requiredSystemFeatures = [ "recursive-nix" ];
|
||||
|
||||
drv = builtins.unsafeDiscardOutputDependency (import ./text-hashed-output.nix).hello.drvPath;
|
||||
|
||||
buildCommand = ''
|
||||
export NIX_CONFIG='experimental-features = nix-command ca-derivations'
|
||||
|
||||
PATH=${builtins.getEnv "EXTRA_PATH"}:$PATH
|
||||
|
||||
# JSON of pre-existing drv
|
||||
nix derivation show $drv | jq .[] > drv0.json
|
||||
|
||||
# Fix name
|
||||
jq < drv0.json '.name = "${innerName}"' > drv1.json
|
||||
|
||||
# Extend `buildCommand`
|
||||
jq < drv1.json '.env.buildCommand += "echo \"I am alive!\" >> $out/hello\n"' > drv0.json
|
||||
|
||||
# Used as our output
|
||||
cp $(nix derivation add < drv0.json) $out
|
||||
'';
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "text";
|
||||
outputHashAlgo = "sha256";
|
||||
}
|
25
tests/dyn-drv/recursive-mod-json.sh
Normal file
25
tests/dyn-drv/recursive-mod-json.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
source common.sh
|
||||
|
||||
# FIXME
|
||||
if [[ $(uname) != Linux ]]; then skipTest "Not running Linux"; fi
|
||||
|
||||
enableFeatures 'recursive-nix'
|
||||
restartDaemon
|
||||
|
||||
clearStore
|
||||
|
||||
rm -f $TEST_ROOT/result
|
||||
|
||||
EXTRA_PATH=$(dirname $(type -p nix)):$(dirname $(type -p jq))
|
||||
export EXTRA_PATH
|
||||
|
||||
# Will produce a drv
|
||||
metaDrv=$(nix-instantiate ./recursive-mod-json.nix)
|
||||
|
||||
# computed "dynamic" derivation
|
||||
drv=$(nix-store -r $metaDrv)
|
||||
|
||||
# build that dyn drv
|
||||
res=$(nix-store -r $drv)
|
||||
|
||||
grep 'I am alive!' $res/hello
|
29
tests/dyn-drv/text-hashed-output.nix
Normal file
29
tests/dyn-drv/text-hashed-output.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
with import ./config.nix;
|
||||
|
||||
# A simple content-addressed derivation.
|
||||
# The derivation can be arbitrarily modified by passing a different `seed`,
|
||||
# but the output will always be the same
|
||||
rec {
|
||||
hello = mkDerivation {
|
||||
name = "hello";
|
||||
buildCommand = ''
|
||||
set -x
|
||||
echo "Building a CA derivation"
|
||||
mkdir -p $out
|
||||
echo "Hello World" > $out/hello
|
||||
'';
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
};
|
||||
producingDrv = mkDerivation {
|
||||
name = "hello.drv";
|
||||
buildCommand = ''
|
||||
echo "Copying the derivation"
|
||||
cp ${builtins.unsafeDiscardOutputDependency hello.drvPath} $out
|
||||
'';
|
||||
__contentAddressed = true;
|
||||
outputHashMode = "text";
|
||||
outputHashAlgo = "sha256";
|
||||
};
|
||||
}
|
26
tests/dyn-drv/text-hashed-output.sh
Normal file
26
tests/dyn-drv/text-hashed-output.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
# In the corresponding nix file, we have two derivations: the first, named root,
|
||||
# is a normal recursive derivation, while the second, named dependent, has the
|
||||
# new outputHashMode "text". Note that in "dependent", we don't refer to the
|
||||
# build output of root, but only to the path of the drv file. For this reason,
|
||||
# we only need to:
|
||||
#
|
||||
# - instantiate the root derivation
|
||||
# - build the dependent derivation
|
||||
# - check that the path of the output coincides with that of the original derivation
|
||||
|
||||
drv=$(nix-instantiate ./text-hashed-output.nix -A hello)
|
||||
nix show-derivation "$drv"
|
||||
|
||||
drvProducingDrv=$(nix-instantiate ./text-hashed-output.nix -A producingDrv)
|
||||
nix show-derivation "$drvProducingDrv"
|
||||
|
||||
out1=$(nix-build ./text-hashed-output.nix -A producingDrv --no-out-link)
|
||||
|
||||
nix path-info $drv --derivation --json | jq
|
||||
nix path-info $out1 --derivation --json | jq
|
||||
|
||||
test $out1 == $drv
|
|
@ -16,9 +16,10 @@ nix eval --expr 'assert 1 + 2 == 3; true'
|
|||
[[ $(nix eval int -f "./eval.nix") == 123 ]]
|
||||
[[ $(nix eval str -f "./eval.nix") == '"foo"' ]]
|
||||
[[ $(nix eval str --raw -f "./eval.nix") == 'foo' ]]
|
||||
[[ $(nix eval attr -f "./eval.nix") == '{ foo = "bar"; }' ]]
|
||||
[[ "$(nix eval attr -f "./eval.nix")" == '{ foo = "bar"; }' ]]
|
||||
[[ $(nix eval attr --json -f "./eval.nix") == '{"foo":"bar"}' ]]
|
||||
[[ $(nix eval int -f - < "./eval.nix") == 123 ]]
|
||||
[[ "$(nix eval --expr '{"assert"=1;bar=2;}')" == '{ "assert" = 1; bar = 2; }' ]]
|
||||
|
||||
# Check if toFile can be utilized during restricted eval
|
||||
[[ $(nix eval --restrict-eval --expr 'import (builtins.toFile "source" "42")') == 42 ]]
|
||||
|
@ -26,10 +27,17 @@ nix eval --expr 'assert 1 + 2 == 3; true'
|
|||
nix-instantiate --eval -E 'assert 1 + 2 == 3; true'
|
||||
[[ $(nix-instantiate -A int --eval "./eval.nix") == 123 ]]
|
||||
[[ $(nix-instantiate -A str --eval "./eval.nix") == '"foo"' ]]
|
||||
[[ $(nix-instantiate -A attr --eval "./eval.nix") == '{ foo = "bar"; }' ]]
|
||||
[[ "$(nix-instantiate -A attr --eval "./eval.nix")" == '{ foo = "bar"; }' ]]
|
||||
[[ $(nix-instantiate -A attr --eval --json "./eval.nix") == '{"foo":"bar"}' ]]
|
||||
[[ $(nix-instantiate -A int --eval - < "./eval.nix") == 123 ]]
|
||||
[[ "$(nix-instantiate --eval -E '{"assert"=1;bar=2;}')" == '{ "assert" = 1; bar = 2; }' ]]
|
||||
|
||||
# Check that symlink cycles don't cause a hang.
|
||||
ln -sfn cycle.nix $TEST_ROOT/cycle.nix
|
||||
(! nix eval --file $TEST_ROOT/cycle.nix)
|
||||
|
||||
# Check that relative symlinks are resolved correctly.
|
||||
mkdir -p $TEST_ROOT/xyzzy $TEST_ROOT/foo
|
||||
ln -sfn ../xyzzy $TEST_ROOT/foo/bar
|
||||
printf 123 > $TEST_ROOT/xyzzy/default.nix
|
||||
[[ $(nix eval --impure --expr "import $TEST_ROOT/foo/bar") = 123 ]]
|
||||
|
|
|
@ -41,10 +41,27 @@ cat > $flake1Dir/flake.nix <<EOF
|
|||
a8 = builtins.storePath $dep;
|
||||
|
||||
a9 = "$dep";
|
||||
|
||||
drvCall = with import ./config.nix; mkDerivation {
|
||||
name = "simple";
|
||||
builder = ./simple.builder.sh;
|
||||
PATH = "";
|
||||
goodPath = path;
|
||||
};
|
||||
|
||||
a10 = builtins.unsafeDiscardOutputDependency self.drvCall.drvPath;
|
||||
|
||||
a11 = self.drvCall.drvPath;
|
||||
|
||||
a12 = self.drvCall.outPath;
|
||||
|
||||
a13 = "\${self.drvCall.drvPath}\${self.drvCall.outPath}";
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
cp ../simple.nix ../simple.builder.sh ../config.nix $flake1Dir/
|
||||
|
||||
echo bar > $flake1Dir/foo
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a1
|
||||
|
@ -63,4 +80,17 @@ nix build --json --out-link $TEST_ROOT/result $flake1Dir#a6
|
|||
nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a8
|
||||
diff common.sh $TEST_ROOT/result
|
||||
|
||||
(! nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a9)
|
||||
expectStderr 1 nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a9 \
|
||||
| grepQuiet "has 0 entries in its context. It should only have exactly one entry"
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a10
|
||||
[[ $(readlink -e $TEST_ROOT/result) = *simple.drv ]]
|
||||
|
||||
expectStderr 1 nix build --json --out-link $TEST_ROOT/result $flake1Dir#a11 \
|
||||
| grepQuiet "has a context which refers to a complete source and binary closure"
|
||||
|
||||
nix build --json --out-link $TEST_ROOT/result $flake1Dir#a12
|
||||
[[ -e $TEST_ROOT/result/hello ]]
|
||||
|
||||
expectStderr 1 nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a13 \
|
||||
| grepQuiet "has 2 entries in its context. It should only have exactly one entry"
|
||||
|
|
|
@ -72,6 +72,8 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
checkRes=$(nix flake check --keep-going $flakeDir 2>&1 && fail "nix flake check should have failed" || true)
|
||||
nix flake check $flakeDir
|
||||
|
||||
checkRes=$(nix flake check --all-systems --keep-going $flakeDir 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
echo "$checkRes" | grepQuiet "packages.system-1.default"
|
||||
echo "$checkRes" | grepQuiet "packages.system-2.default"
|
||||
|
|
17
tests/gc.sh
17
tests/gc.sh
|
@ -52,9 +52,7 @@ rmdir $NIX_STORE_DIR/.links
|
|||
rmdir $NIX_STORE_DIR
|
||||
|
||||
## Test `nix-collect-garbage -d`
|
||||
# `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're
|
||||
# using them
|
||||
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
testCollectGarbageD () {
|
||||
clearProfiles
|
||||
# Run two `nix-env` commands, should create two generations of
|
||||
# the profile
|
||||
|
@ -66,4 +64,17 @@ if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
|||
# left
|
||||
nix-collect-garbage -d
|
||||
[[ $(nix-env --list-generations | wc -l) -eq 1 ]]
|
||||
}
|
||||
# `nix-env` doesn't work with CA derivations, so let's ignore that bit if we're
|
||||
# using them
|
||||
if [[ -z "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
testCollectGarbageD
|
||||
|
||||
# Run the same test, but forcing the profiles at their legacy location under
|
||||
# /nix/var/nix.
|
||||
#
|
||||
# Regression test for #8294
|
||||
rm ~/.nix-profile
|
||||
ln -s $NIX_STATE_DIR/profiles/per-user/me ~/.nix-profile
|
||||
testCollectGarbageD
|
||||
fi
|
||||
|
|
130
tests/lang/eval-fail-fromTOML-timestamps.nix
Normal file
130
tests/lang/eval-fail-fromTOML-timestamps.nix
Normal file
|
@ -0,0 +1,130 @@
|
|||
builtins.fromTOML ''
|
||||
key = "value"
|
||||
bare_key = "value"
|
||||
bare-key = "value"
|
||||
1234 = "value"
|
||||
|
||||
"127.0.0.1" = "value"
|
||||
"character encoding" = "value"
|
||||
"ʎǝʞ" = "value"
|
||||
'key2' = "value"
|
||||
'quoted "value"' = "value"
|
||||
|
||||
name = "Orange"
|
||||
|
||||
physical.color = "orange"
|
||||
physical.shape = "round"
|
||||
site."google.com" = true
|
||||
|
||||
# This is legal according to the spec, but cpptoml doesn't handle it.
|
||||
#a.b.c = 1
|
||||
#a.d = 2
|
||||
|
||||
str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
|
||||
|
||||
int1 = +99
|
||||
int2 = 42
|
||||
int3 = 0
|
||||
int4 = -17
|
||||
int5 = 1_000
|
||||
int6 = 5_349_221
|
||||
int7 = 1_2_3_4_5
|
||||
|
||||
hex1 = 0xDEADBEEF
|
||||
hex2 = 0xdeadbeef
|
||||
hex3 = 0xdead_beef
|
||||
|
||||
oct1 = 0o01234567
|
||||
oct2 = 0o755
|
||||
|
||||
bin1 = 0b11010110
|
||||
|
||||
flt1 = +1.0
|
||||
flt2 = 3.1415
|
||||
flt3 = -0.01
|
||||
flt4 = 5e+22
|
||||
flt5 = 1e6
|
||||
flt6 = -2E-2
|
||||
flt7 = 6.626e-34
|
||||
flt8 = 9_224_617.445_991_228_313
|
||||
|
||||
bool1 = true
|
||||
bool2 = false
|
||||
|
||||
odt1 = 1979-05-27T07:32:00Z
|
||||
odt2 = 1979-05-27T00:32:00-07:00
|
||||
odt3 = 1979-05-27T00:32:00.999999-07:00
|
||||
odt4 = 1979-05-27 07:32:00Z
|
||||
ldt1 = 1979-05-27T07:32:00
|
||||
ldt2 = 1979-05-27T00:32:00.999999
|
||||
ld1 = 1979-05-27
|
||||
lt1 = 07:32:00
|
||||
lt2 = 00:32:00.999999
|
||||
|
||||
arr1 = [ 1, 2, 3 ]
|
||||
arr2 = [ "red", "yellow", "green" ]
|
||||
arr3 = [ [ 1, 2 ], [3, 4, 5] ]
|
||||
arr4 = [ "all", 'strings', """are the same""", ''''type'''']
|
||||
arr5 = [ [ 1, 2 ], ["a", "b", "c"] ]
|
||||
|
||||
arr7 = [
|
||||
1, 2, 3
|
||||
]
|
||||
|
||||
arr8 = [
|
||||
1,
|
||||
2, # this is ok
|
||||
]
|
||||
|
||||
[table-1]
|
||||
key1 = "some string"
|
||||
key2 = 123
|
||||
|
||||
|
||||
[table-2]
|
||||
key1 = "another string"
|
||||
key2 = 456
|
||||
|
||||
[dog."tater.man"]
|
||||
type.name = "pug"
|
||||
|
||||
[a.b.c]
|
||||
[ d.e.f ]
|
||||
[ g . h . i ]
|
||||
[ j . "ʞ" . 'l' ]
|
||||
[x.y.z.w]
|
||||
|
||||
name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
animal = { type.name = "pug" }
|
||||
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
|
||||
[[products]]
|
||||
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
color = "gray"
|
||||
|
||||
[[fruit]]
|
||||
name = "apple"
|
||||
|
||||
[fruit.physical]
|
||||
color = "red"
|
||||
shape = "round"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "red delicious"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "granny smith"
|
||||
|
||||
[[fruit]]
|
||||
name = "banana"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "plantain"
|
||||
''
|
1
tests/lang/eval-okay-fromTOML-timestamps.exp
Normal file
1
tests/lang/eval-okay-fromTOML-timestamps.exp
Normal file
|
@ -0,0 +1 @@
|
|||
{ "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; ld1 = { _type = "timestamp"; value = "1979-05-27"; }; ldt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00"; }; ldt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999"; }; lt1 = { _type = "timestamp"; value = "07:32:00"; }; lt2 = { _type = "timestamp"; value = "00:32:00.999999"; }; name = "Orange"; oct1 = 342391; oct2 = 493; odt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; odt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00-07:00"; }; odt3 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999-07:00"; }; odt4 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; }
|
1
tests/lang/eval-okay-fromTOML-timestamps.flags
Normal file
1
tests/lang/eval-okay-fromTOML-timestamps.flags
Normal file
|
@ -0,0 +1 @@
|
|||
--extra-experimental-features parse-toml-timestamps
|
130
tests/lang/eval-okay-fromTOML-timestamps.nix
Normal file
130
tests/lang/eval-okay-fromTOML-timestamps.nix
Normal file
|
@ -0,0 +1,130 @@
|
|||
builtins.fromTOML ''
|
||||
key = "value"
|
||||
bare_key = "value"
|
||||
bare-key = "value"
|
||||
1234 = "value"
|
||||
|
||||
"127.0.0.1" = "value"
|
||||
"character encoding" = "value"
|
||||
"ʎǝʞ" = "value"
|
||||
'key2' = "value"
|
||||
'quoted "value"' = "value"
|
||||
|
||||
name = "Orange"
|
||||
|
||||
physical.color = "orange"
|
||||
physical.shape = "round"
|
||||
site."google.com" = true
|
||||
|
||||
# This is legal according to the spec, but cpptoml doesn't handle it.
|
||||
#a.b.c = 1
|
||||
#a.d = 2
|
||||
|
||||
str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
|
||||
|
||||
int1 = +99
|
||||
int2 = 42
|
||||
int3 = 0
|
||||
int4 = -17
|
||||
int5 = 1_000
|
||||
int6 = 5_349_221
|
||||
int7 = 1_2_3_4_5
|
||||
|
||||
hex1 = 0xDEADBEEF
|
||||
hex2 = 0xdeadbeef
|
||||
hex3 = 0xdead_beef
|
||||
|
||||
oct1 = 0o01234567
|
||||
oct2 = 0o755
|
||||
|
||||
bin1 = 0b11010110
|
||||
|
||||
flt1 = +1.0
|
||||
flt2 = 3.1415
|
||||
flt3 = -0.01
|
||||
flt4 = 5e+22
|
||||
flt5 = 1e6
|
||||
flt6 = -2E-2
|
||||
flt7 = 6.626e-34
|
||||
flt8 = 9_224_617.445_991_228_313
|
||||
|
||||
bool1 = true
|
||||
bool2 = false
|
||||
|
||||
odt1 = 1979-05-27T07:32:00Z
|
||||
odt2 = 1979-05-27T00:32:00-07:00
|
||||
odt3 = 1979-05-27T00:32:00.999999-07:00
|
||||
odt4 = 1979-05-27 07:32:00Z
|
||||
ldt1 = 1979-05-27T07:32:00
|
||||
ldt2 = 1979-05-27T00:32:00.999999
|
||||
ld1 = 1979-05-27
|
||||
lt1 = 07:32:00
|
||||
lt2 = 00:32:00.999999
|
||||
|
||||
arr1 = [ 1, 2, 3 ]
|
||||
arr2 = [ "red", "yellow", "green" ]
|
||||
arr3 = [ [ 1, 2 ], [3, 4, 5] ]
|
||||
arr4 = [ "all", 'strings', """are the same""", ''''type'''']
|
||||
arr5 = [ [ 1, 2 ], ["a", "b", "c"] ]
|
||||
|
||||
arr7 = [
|
||||
1, 2, 3
|
||||
]
|
||||
|
||||
arr8 = [
|
||||
1,
|
||||
2, # this is ok
|
||||
]
|
||||
|
||||
[table-1]
|
||||
key1 = "some string"
|
||||
key2 = 123
|
||||
|
||||
|
||||
[table-2]
|
||||
key1 = "another string"
|
||||
key2 = 456
|
||||
|
||||
[dog."tater.man"]
|
||||
type.name = "pug"
|
||||
|
||||
[a.b.c]
|
||||
[ d.e.f ]
|
||||
[ g . h . i ]
|
||||
[ j . "ʞ" . 'l' ]
|
||||
[x.y.z.w]
|
||||
|
||||
name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
animal = { type.name = "pug" }
|
||||
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
|
||||
[[products]]
|
||||
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
color = "gray"
|
||||
|
||||
[[fruit]]
|
||||
name = "apple"
|
||||
|
||||
[fruit.physical]
|
||||
color = "red"
|
||||
shape = "round"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "red delicious"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "granny smith"
|
||||
|
||||
[[fruit]]
|
||||
name = "banana"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "plantain"
|
||||
''
|
|
@ -1 +1 @@
|
|||
[ "faabar" "fbar" "fubar" "faboor" "fubar" "XaXbXcX" "X" "a_b" ]
|
||||
[ "faabar" "fbar" "fubar" "faboor" "fubar" "XaXbXcX" "X" "a_b" "fubar" ]
|
||||
|
|
|
@ -8,4 +8,5 @@ with builtins;
|
|||
(replaceStrings [""] ["X"] "abc")
|
||||
(replaceStrings [""] ["X"] "")
|
||||
(replaceStrings ["-"] ["_"] "a-b")
|
||||
(replaceStrings ["oo" "XX"] ["u" (throw "unreachable")] "foobar")
|
||||
]
|
||||
|
|
29
tests/linux-sandbox-cert-test.nix
Normal file
29
tests/linux-sandbox-cert-test.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{ fixed-output }:
|
||||
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation ({
|
||||
name = "ssl-export";
|
||||
buildCommand = ''
|
||||
# Add some indirection, otherwise grepping into the debug output finds the string.
|
||||
report () { echo CERT_$1_IN_SANDBOX; }
|
||||
|
||||
if [ -f /etc/ssl/certs/ca-certificates.crt ]; then
|
||||
content=$(</etc/ssl/certs/ca-certificates.crt)
|
||||
if [ "$content" == CERT_CONTENT ]; then
|
||||
report present
|
||||
fi
|
||||
else
|
||||
report missing
|
||||
fi
|
||||
|
||||
# Always fail, because we do not want to bother with fixed-output
|
||||
# derivations being cached, and do not want to compute the right hash.
|
||||
false;
|
||||
'';
|
||||
} // (
|
||||
if fixed-output == "fixed-output"
|
||||
then { outputHash = "sha256:0000000000000000000000000000000000000000000000000000000000000000"; }
|
||||
else { }
|
||||
))
|
||||
|
|
@ -40,3 +40,27 @@ grepQuiet 'may not be deterministic' $TEST_ROOT/log
|
|||
|
||||
# Test that sandboxed builds cannot write to /etc easily
|
||||
(! nix-build -E 'with import ./config.nix; mkDerivation { name = "etc-write"; buildCommand = "echo > /etc/test"; }' --no-out-link --sandbox-paths /nix/store)
|
||||
|
||||
|
||||
## Test mounting of SSL certificates into the sandbox
|
||||
testCert () {
|
||||
(! nix-build linux-sandbox-cert-test.nix --argstr fixed-output "$2" --no-out-link --sandbox-paths /nix/store --option ssl-cert-file "$3" 2> $TEST_ROOT/log)
|
||||
cat $TEST_ROOT/log
|
||||
grepQuiet "CERT_${1}_IN_SANDBOX" $TEST_ROOT/log
|
||||
}
|
||||
|
||||
nocert=$TEST_ROOT/no-cert-file.pem
|
||||
cert=$TEST_ROOT/some-cert-file.pem
|
||||
echo -n "CERT_CONTENT" > $cert
|
||||
|
||||
# No cert in sandbox when not a fixed-output derivation
|
||||
testCert missing normal "$cert"
|
||||
|
||||
# No cert in sandbox when ssl-cert-file is empty
|
||||
testCert missing fixed-output ""
|
||||
|
||||
# No cert in sandbox when ssl-cert-file is a nonexistent file
|
||||
testCert missing fixed-output "$nocert"
|
||||
|
||||
# Cert in sandbox when ssl-cert-file is set to an existing file
|
||||
testCert present fixed-output "$cert"
|
||||
|
|
|
@ -72,6 +72,7 @@ nix_tests = \
|
|||
build-remote-content-addressed-floating.sh \
|
||||
build-remote-trustless-should-pass-0.sh \
|
||||
build-remote-trustless-should-pass-1.sh \
|
||||
build-remote-trustless-should-pass-2.sh \
|
||||
build-remote-trustless-should-pass-3.sh \
|
||||
build-remote-trustless-should-fail-0.sh \
|
||||
nar-access.sh \
|
||||
|
@ -110,6 +111,8 @@ nix_tests = \
|
|||
ca/derivation-json.sh \
|
||||
import-derivation.sh \
|
||||
ca/import-derivation.sh \
|
||||
dyn-drv/text-hashed-output.sh \
|
||||
dyn-drv/recursive-mod-json.sh \
|
||||
nix_path.sh \
|
||||
case-hack.sh \
|
||||
placeholders.sh \
|
||||
|
@ -137,11 +140,19 @@ ifeq ($(HAVE_LIBCPUID), 1)
|
|||
nix_tests += compute-levels.sh
|
||||
endif
|
||||
|
||||
install-tests += $(foreach x, $(nix_tests), tests/$(x))
|
||||
install-tests += $(foreach x, $(nix_tests), $(d)/$(x))
|
||||
|
||||
clean-files += $(d)/common/vars-and-functions.sh $(d)/config.nix $(d)/ca/config.nix
|
||||
clean-files += \
|
||||
$(d)/common/vars-and-functions.sh \
|
||||
$(d)/config.nix \
|
||||
$(d)/ca/config.nix \
|
||||
$(d)/dyn-drv/config.nix
|
||||
|
||||
test-deps += tests/common/vars-and-functions.sh tests/config.nix tests/ca/config.nix
|
||||
test-deps += \
|
||||
tests/common/vars-and-functions.sh \
|
||||
tests/config.nix \
|
||||
tests/ca/config.nix \
|
||||
tests/dyn-drv/config.nix
|
||||
|
||||
ifeq ($(BUILD_SHARED_LIBS), 1)
|
||||
test-deps += tests/plugins/libplugintest.$(SO_EXT)
|
||||
|
|
|
@ -157,17 +157,17 @@ error: An existing package already provides the following file:
|
|||
|
||||
To remove the existing package:
|
||||
|
||||
nix profile remove path:${flake1Dir}
|
||||
nix profile remove path:${flake1Dir}#packages.${system}.default
|
||||
|
||||
The new package can also be installed next to the existing one by assigning a different priority.
|
||||
The conflicting packages have a priority of 5.
|
||||
To prioritise the new package:
|
||||
|
||||
nix profile install path:${flake2Dir} --priority 4
|
||||
nix profile install path:${flake2Dir}#packages.${system}.default --priority 4
|
||||
|
||||
To prioritise the existing package:
|
||||
|
||||
nix profile install path:${flake2Dir} --priority 6
|
||||
nix profile install path:${flake2Dir}#packages.${system}.default --priority 6
|
||||
EOF
|
||||
)
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
|
@ -177,3 +177,10 @@ nix profile install $flake2Dir --priority 0
|
|||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World2" ]]
|
||||
# nix profile install $flake1Dir --priority 100
|
||||
# [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
|
||||
# Ensure that conflicts are handled properly even when the installables aren't
|
||||
# flake references.
|
||||
# Regression test for https://github.com/NixOS/nix/issues/8284
|
||||
clearProfiles
|
||||
nix profile install $(nix build $flake1Dir --no-link --print-out-paths)
|
||||
expect 1 nix profile install --impure --expr "(builtins.getFlake ''$flake2Dir'').packages.$system.default"
|
||||
|
|
|
@ -98,6 +98,18 @@ nix develop -f "$shellDotNix" shellDrv -c echo foo |& grepQuiet foo
|
|||
nix print-dev-env -f "$shellDotNix" shellDrv > $TEST_ROOT/dev-env.sh
|
||||
nix print-dev-env -f "$shellDotNix" shellDrv --json > $TEST_ROOT/dev-env.json
|
||||
|
||||
# Test with raw drv
|
||||
|
||||
shellDrv=$(nix-instantiate "$shellDotNix" -A shellDrv.out)
|
||||
|
||||
nix develop $shellDrv -c bash -c '[[ -n $stdenv ]]'
|
||||
|
||||
nix print-dev-env $shellDrv > $TEST_ROOT/dev-env2.sh
|
||||
nix print-dev-env $shellDrv --json > $TEST_ROOT/dev-env2.json
|
||||
|
||||
diff $TEST_ROOT/dev-env{,2}.sh
|
||||
diff $TEST_ROOT/dev-env{,2}.json
|
||||
|
||||
# Ensure `nix print-dev-env --json` contains variable assignments.
|
||||
[[ $(jq -r .variables.arr1.value[2] $TEST_ROOT/dev-env.json) = '3 4' ]]
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@ in {
|
|||
nix.settings.substituters = lib.mkForce [ ];
|
||||
nix.settings.experimental-features = [ "nix-command" ];
|
||||
services.getty.autologinUser = "root";
|
||||
programs.ssh.extraConfig = ''
|
||||
Host *
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/master-%h:%r@%n:%p
|
||||
ControlPersist 15m
|
||||
'';
|
||||
};
|
||||
|
||||
server =
|
||||
|
@ -62,6 +68,10 @@ in {
|
|||
client.wait_for_text("done")
|
||||
server.succeed("nix-store --check-validity ${pkgA}")
|
||||
|
||||
# Check that ControlMaster is working
|
||||
client.send_chars("nix copy --to ssh://server ${pkgA} >&2; echo done\n")
|
||||
client.wait_for_text("done")
|
||||
|
||||
client.copy_from_host("key", "/root/.ssh/id_ed25519")
|
||||
client.succeed("chmod 600 /root/.ssh/id_ed25519")
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@ libplugintest_ALLOW_UNDEFINED := 1
|
|||
|
||||
libplugintest_EXCLUDE_FROM_LIBRARY_LIST := 1
|
||||
|
||||
libplugintest_CXXFLAGS := -I src/libutil -I src/libstore -I src/libexpr
|
||||
libplugintest_CXXFLAGS := -I src/libutil -I src/libstore -I src/libexpr -I src/libfetchers
|
||||
|
|
|
@ -17,6 +17,10 @@ fi
|
|||
|
||||
# Build the dependencies and push them to the remote store.
|
||||
nix-build -o $TEST_ROOT/result dependencies.nix --post-build-hook "$pushToStore"
|
||||
# See if all outputs are passed to the post-build hook by only specifying one
|
||||
# We're not able to test CA tests this way
|
||||
export BUILD_HOOK_ONLY_OUT_PATHS=$([ ! $NIX_TESTS_CA_BY_DEFAULT ])
|
||||
nix-build -o $TEST_ROOT/result-mult multiple-outputs.nix -A a.first --post-build-hook "$pushToStore"
|
||||
|
||||
clearStore
|
||||
|
||||
|
@ -24,3 +28,4 @@ clearStore
|
|||
# closure of what we've just built.
|
||||
nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix
|
||||
nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix input1_drv
|
||||
nix copy --from "$REMOTE_STORE" --no-require-sigs -f multiple-outputs.nix a^second
|
||||
|
|
|
@ -7,4 +7,8 @@ set -e
|
|||
[ -n "$DRV_PATH" ]
|
||||
|
||||
echo Pushing "$OUT_PATHS" to "$REMOTE_STORE"
|
||||
printf "%s" "$DRV_PATH" | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs
|
||||
if [ -n "$BUILD_HOOK_ONLY_OUT_PATHS" ]; then
|
||||
printf "%s" "$OUT_PATHS" | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs
|
||||
else
|
||||
printf "%s" "$DRV_PATH" | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs
|
||||
fi
|
||||
|
|
|
@ -7,4 +7,8 @@ set -e
|
|||
[ -n "$DRV_PATH" ]
|
||||
|
||||
echo Pushing "$OUT_PATHS" to "$REMOTE_STORE"
|
||||
printf "%s" "$DRV_PATH"^'*' | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs
|
||||
if [ -n "$BUILD_HOOK_ONLY_OUT_PATHS" ]; then
|
||||
printf "%s" "$OUT_PATHS" | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs
|
||||
else
|
||||
printf "%s" "$DRV_PATH"^'*' | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
source common.sh
|
||||
|
||||
sed -i 's/experimental-features .*/& recursive-nix/' "$NIX_CONF_DIR"/nix.conf
|
||||
enableFeatures 'recursive-nix'
|
||||
restartDaemon
|
||||
|
||||
clearStore
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue