mirror of
https://github.com/NixOS/nix
synced 2025-07-09 03:43:54 +02:00
Merge 'nix flake {info,list-inputs}' into 'nix flake metadata'
Fixes #4613.
This commit is contained in:
parent
77f5d171e1
commit
66fa1c7375
4 changed files with 92 additions and 130 deletions
|
@ -164,16 +164,17 @@ EOF
|
|||
# Test 'nix flake list'.
|
||||
[[ $(nix registry list | wc -l) == 7 ]]
|
||||
|
||||
# Test 'nix flake info'.
|
||||
nix flake info flake1 | grep -q 'URL: .*flake1.*'
|
||||
# Test 'nix flake metadata'.
|
||||
nix flake metadata flake1
|
||||
nix flake metadata flake1 | grep -q 'Locked URL:.*flake1.*'
|
||||
|
||||
# Test 'nix flake info' on a local flake.
|
||||
(cd $flake1Dir && nix flake info) | grep -q 'URL: .*flake1.*'
|
||||
(cd $flake1Dir && nix flake info .) | grep -q 'URL: .*flake1.*'
|
||||
nix flake info $flake1Dir | grep -q 'URL: .*flake1.*'
|
||||
# Test 'nix flake metadata' on a local flake.
|
||||
(cd $flake1Dir && nix flake metadata) | grep -q 'URL:.*flake1.*'
|
||||
(cd $flake1Dir && nix flake metadata .) | grep -q 'URL:.*flake1.*'
|
||||
nix flake metadata $flake1Dir | grep -q 'URL:.*flake1.*'
|
||||
|
||||
# Test 'nix flake info --json'.
|
||||
json=$(nix flake info flake1 --json | jq .)
|
||||
# Test 'nix flake metadata --json'.
|
||||
json=$(nix flake metadata flake1 --json | jq .)
|
||||
[[ $(echo "$json" | jq -r .description) = 'Bla bla' ]]
|
||||
[[ -d $(echo "$json" | jq -r .path) ]]
|
||||
[[ $(echo "$json" | jq -r .lastModified) = $(git -C $flake1Dir log -n1 --format=%ct) ]]
|
||||
|
@ -181,7 +182,7 @@ hash1=$(echo "$json" | jq -r .revision)
|
|||
|
||||
echo -n '# foo' >> $flake1Dir/flake.nix
|
||||
git -C $flake1Dir commit -a -m 'Foo'
|
||||
hash2=$(nix flake info flake1 --json --refresh | jq -r .revision)
|
||||
hash2=$(nix flake metadata flake1 --json --refresh | jq -r .revision)
|
||||
[[ $hash1 != $hash2 ]]
|
||||
|
||||
# Test 'nix build' on a flake.
|
||||
|
@ -630,7 +631,7 @@ hg commit --config ui.username=foobar@example.org $flake5Dir -m 'Initial commit'
|
|||
nix build -o $TEST_ROOT/result hg+file://$flake5Dir
|
||||
[[ -e $TEST_ROOT/result/hello ]]
|
||||
|
||||
(! nix flake info --json hg+file://$flake5Dir | jq -e -r .revision)
|
||||
(! nix flake metadata --json hg+file://$flake5Dir | jq -e -r .revision)
|
||||
|
||||
nix eval hg+file://$flake5Dir#expr
|
||||
|
||||
|
@ -638,13 +639,13 @@ nix eval hg+file://$flake5Dir#expr
|
|||
|
||||
(! nix eval hg+file://$flake5Dir#expr --no-allow-dirty)
|
||||
|
||||
(! nix flake info --json hg+file://$flake5Dir | jq -e -r .revision)
|
||||
(! nix flake metadata --json hg+file://$flake5Dir | jq -e -r .revision)
|
||||
|
||||
hg commit --config ui.username=foobar@example.org $flake5Dir -m 'Add lock file'
|
||||
|
||||
nix flake info --json hg+file://$flake5Dir --refresh | jq -e -r .revision
|
||||
nix flake info --json hg+file://$flake5Dir
|
||||
[[ $(nix flake info --json hg+file://$flake5Dir | jq -e -r .revCount) = 1 ]]
|
||||
nix flake metadata --json hg+file://$flake5Dir --refresh | jq -e -r .revision
|
||||
nix flake metadata --json hg+file://$flake5Dir
|
||||
[[ $(nix flake metadata --json hg+file://$flake5Dir | jq -e -r .revCount) = 1 ]]
|
||||
|
||||
nix build -o $TEST_ROOT/result hg+file://$flake5Dir --no-registries --no-allow-dirty
|
||||
|
||||
|
@ -654,7 +655,7 @@ tar cfz $TEST_ROOT/flake.tar.gz -C $TEST_ROOT --exclude .hg flake5
|
|||
nix build -o $TEST_ROOT/result file://$TEST_ROOT/flake.tar.gz
|
||||
|
||||
# Building with a tarball URL containing a SRI hash should also work.
|
||||
url=$(nix flake info --json file://$TEST_ROOT/flake.tar.gz | jq -r .url)
|
||||
url=$(nix flake metadata --json file://$TEST_ROOT/flake.tar.gz | jq -r .url)
|
||||
[[ $url =~ sha256- ]]
|
||||
|
||||
nix build -o $TEST_ROOT/result $url
|
||||
|
@ -680,9 +681,8 @@ nix flake lock $flake3Dir
|
|||
nix flake lock $flake3Dir --update-input flake2/flake1
|
||||
[[ $(jq -r .nodes.flake1_2.locked.rev $flake3Dir/flake.lock) =~ $hash2 ]]
|
||||
|
||||
# Test 'nix flake list-inputs'.
|
||||
[[ $(nix flake list-inputs $flake3Dir | wc -l) == 5 ]]
|
||||
nix flake list-inputs $flake3Dir --json | jq .
|
||||
# Test 'nix flake metadata --json'.
|
||||
nix flake metadata $flake3Dir --json | jq .
|
||||
|
||||
# Test circular flake dependencies.
|
||||
cat > $flakeA/flake.nix <<EOF
|
||||
|
@ -721,4 +721,4 @@ git -C $flakeB commit -a -m 'Foo'
|
|||
[[ $(nix eval --update-input b $flakeA#foo) = 1912 ]]
|
||||
|
||||
# Test list-inputs with circular dependencies
|
||||
nix flake list-inputs $flakeA
|
||||
nix flake metadata $flakeA
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue