mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Merge remote-tracking branch 'upstream/master' into indexed-store-path-outputs
This commit is contained in:
commit
dabb03b8d0
62 changed files with 406 additions and 249 deletions
|
@ -29,3 +29,7 @@ nix-instantiate --eval -E 'assert 1 + 2 == 3; true'
|
|||
[[ $(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 ]]
|
||||
|
||||
# Check that symlink cycles don't cause a hang.
|
||||
ln -sfn cycle.nix $TEST_ROOT/cycle.nix
|
||||
(! nix eval --file $TEST_ROOT/cycle.nix)
|
||||
|
|
|
@ -122,6 +122,7 @@ git -C $repo commit -m 'Bla3' -a
|
|||
path4=$(nix eval --impure --refresh --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
||||
[[ $path2 = $path4 ]]
|
||||
|
||||
status=0
|
||||
nix eval --impure --raw --expr "(builtins.fetchGit { url = $repo; rev = \"$rev2\"; narHash = \"sha256-B5yIPHhEm0eysJKEsO7nqxprh9vcblFxpJG11gXJus1=\"; }).outPath" || status=$?
|
||||
[[ "$status" = "102" ]]
|
||||
|
||||
|
|
17
tests/flakes/absolute-paths.sh
Normal file
17
tests/flakes/absolute-paths.sh
Normal file
|
@ -0,0 +1,17 @@
|
|||
source ./common.sh
|
||||
|
||||
requireGit
|
||||
|
||||
flake1Dir=$TEST_ROOT/flake1
|
||||
flake2Dir=$TEST_ROOT/flake2
|
||||
|
||||
createGitRepo $flake1Dir
|
||||
cat > $flake1Dir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: { x = builtins.readFile $(pwd)/absolute-paths.sh; };
|
||||
}
|
||||
EOF
|
||||
git -C $flake1Dir add flake.nix
|
||||
git -C $flake1Dir commit -m Initial
|
||||
|
||||
nix eval --impure --json $flake1Dir#x
|
|
@ -53,7 +53,11 @@ cat > $flake3Dir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
git -C $flake3Dir add flake.nix
|
||||
cat > $flake3Dir/default.nix <<EOF
|
||||
{ x = 123; }
|
||||
EOF
|
||||
|
||||
git -C $flake3Dir add flake.nix default.nix
|
||||
git -C $flake3Dir commit -m 'Initial'
|
||||
|
||||
cat > $nonFlakeDir/README.md <<EOF
|
||||
|
@ -109,11 +113,12 @@ nix build -o $TEST_ROOT/result git+file://$flake1Dir
|
|||
nix build -o $flake1Dir/result git+file://$flake1Dir
|
||||
nix path-info $flake1Dir/result
|
||||
|
||||
# 'getFlake' on a mutable flakeref should fail in pure mode, but succeed in impure mode.
|
||||
# 'getFlake' on an unlocked flakeref should fail in pure mode, but
|
||||
# succeed in impure mode.
|
||||
(! nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default")
|
||||
nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default" --impure
|
||||
|
||||
# 'getFlake' on an immutable flakeref should succeed even in pure mode.
|
||||
# 'getFlake' on a locked flakeref should succeed even in pure mode.
|
||||
nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash2\").packages.$system.default"
|
||||
|
||||
# Building a flake with an unlocked dependency should fail in pure mode.
|
||||
|
@ -460,7 +465,7 @@ nix flake lock $flake3Dir --update-input flake2/flake1
|
|||
# Test 'nix flake metadata --json'.
|
||||
nix flake metadata $flake3Dir --json | jq .
|
||||
|
||||
# Test flake in store does not evaluate
|
||||
# Test flake in store does not evaluate.
|
||||
rm -rf $badFlakeDir
|
||||
mkdir $badFlakeDir
|
||||
echo INVALID > $badFlakeDir/flake.nix
|
||||
|
|
30
tests/flakes/unlocked-override.sh
Normal file
30
tests/flakes/unlocked-override.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
source ./common.sh
|
||||
|
||||
requireGit
|
||||
|
||||
flake1Dir=$TEST_ROOT/flake1
|
||||
flake2Dir=$TEST_ROOT/flake2
|
||||
|
||||
createGitRepo $flake1Dir
|
||||
cat > $flake1Dir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: { x = import ./x.nix; };
|
||||
}
|
||||
EOF
|
||||
echo 123 > $flake1Dir/x.nix
|
||||
git -C $flake1Dir add flake.nix x.nix
|
||||
git -C $flake1Dir commit -m Initial
|
||||
|
||||
createGitRepo $flake2Dir
|
||||
cat > $flake2Dir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self, flake1 }: { x = flake1.x; };
|
||||
}
|
||||
EOF
|
||||
git -C $flake2Dir add flake.nix
|
||||
|
||||
[[ $(nix eval --json $flake2Dir#x --override-input flake1 $TEST_ROOT/flake1) = 123 ]]
|
||||
|
||||
echo 456 > $flake1Dir/x.nix
|
||||
|
||||
[[ $(nix eval --json $flake2Dir#x --override-input flake1 $TEST_ROOT/flake1) = 456 ]]
|
|
@ -11,7 +11,7 @@ expect_trace() {
|
|||
--expr "$expr" 2>&1 \
|
||||
| grep "function-trace" \
|
||||
| sed -e 's/ [0-9]*$//'
|
||||
);
|
||||
)
|
||||
|
||||
echo -n "Tracing expression '$expr'"
|
||||
set +e
|
||||
|
|
|
@ -7,6 +7,8 @@ nix_tests = \
|
|||
flakes/follow-paths.sh \
|
||||
flakes/bundle.sh \
|
||||
flakes/check.sh \
|
||||
flakes/unlocked-override.sh \
|
||||
flakes/absolute-paths.sh \
|
||||
ca/gc.sh \
|
||||
gc.sh \
|
||||
remote-store.sh \
|
||||
|
@ -110,7 +112,8 @@ nix_tests = \
|
|||
fetchClosure.sh \
|
||||
completions.sh \
|
||||
impure-derivations.sh \
|
||||
path-from-hash-part.sh
|
||||
path-from-hash-part.sh \
|
||||
toString-path.sh
|
||||
|
||||
ifeq ($(HAVE_LIBCPUID), 1)
|
||||
nix_tests += compute-levels.sh
|
||||
|
|
|
@ -9,3 +9,6 @@ nix-instantiate --eval -E '<by-relative-path/simple.nix>' --restrict-eval
|
|||
|
||||
# Should ideally also test this, but there’s no pure way to do it, so just trust me that it works
|
||||
# nix-instantiate --eval -E '<nixpkgs>' -I nixpkgs=channel:nixos-unstable --restrict-eval
|
||||
|
||||
[[ $(nix-instantiate --find-file by-absolute-path/simple.nix) = $PWD/simple.nix ]]
|
||||
[[ $(nix-instantiate --find-file by-relative-path/simple.nix) = $PWD/simple.nix ]]
|
||||
|
|
|
@ -3,7 +3,7 @@ source common.sh
|
|||
clearStore
|
||||
|
||||
nix-instantiate --restrict-eval --eval -E '1 + 2'
|
||||
(! nix-instantiate --restrict-eval ./restricted.nix)
|
||||
(! nix-instantiate --eval --restrict-eval ./restricted.nix)
|
||||
(! nix-instantiate --eval --restrict-eval <(echo '1 + 2'))
|
||||
nix-instantiate --restrict-eval ./simple.nix -I src=.
|
||||
nix-instantiate --restrict-eval ./simple.nix -I src1=simple.nix -I src2=config.nix -I src3=./simple.builder.sh
|
||||
|
|
8
tests/toString-path.sh
Normal file
8
tests/toString-path.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
source common.sh
|
||||
|
||||
mkdir -p $TEST_ROOT/foo
|
||||
echo bla > $TEST_ROOT/foo/bar
|
||||
|
||||
[[ $(nix eval --raw --impure --expr "builtins.readFile (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; } + \"/bar\"))") = bla ]]
|
||||
|
||||
[[ $(nix eval --json --impure --expr "builtins.readDir (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; }))") = '{"bar":"regular"}' ]]
|
Loading…
Add table
Add a link
Reference in a new issue