mirror of
https://github.com/NixOS/nix
synced 2025-07-10 04:43:53 +02:00
Move NAR-related commands to 'nix nar'
This commit is contained in:
parent
79c1967ded
commit
ef583303f0
6 changed files with 54 additions and 27 deletions
|
@ -196,13 +196,13 @@ narCache=$TEST_ROOT/nar-cache
|
|||
rm -rf $narCache
|
||||
mkdir $narCache
|
||||
|
||||
[[ $(nix cat-store --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
|
||||
rm -rfv "$cacheDir/nar"
|
||||
|
||||
[[ $(nix cat-store --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
[[ $(nix store cat --store "file://$cacheDir?local-nar-cache=$narCache" $outPath/foobar) = FOOBAR ]]
|
||||
|
||||
(! nix cat-store --store file://$cacheDir $outPath/foobar)
|
||||
(! nix store cat --store file://$cacheDir $outPath/foobar)
|
||||
|
||||
|
||||
# Test NAR listing generation.
|
||||
|
|
|
@ -22,9 +22,9 @@ outPath=$(nix-build dependencies.nix --no-out-link --sandbox-paths /nix/store)
|
|||
|
||||
nix path-info -r $outPath | grep input-2
|
||||
|
||||
nix ls-store -R -l $outPath | grep foobar
|
||||
nix store ls -R -l $outPath | grep foobar
|
||||
|
||||
nix cat-store $outPath/foobar | grep FOOBAR
|
||||
nix store cat $outPath/foobar | grep FOOBAR
|
||||
|
||||
# Test --check without hash rewriting.
|
||||
nix-build dependencies.nix --no-out-link --check --sandbox-paths /nix/store
|
||||
|
|
|
@ -9,45 +9,45 @@ cd "$TEST_ROOT"
|
|||
narFile="$TEST_ROOT/path.nar"
|
||||
nix-store --dump $storePath > $narFile
|
||||
|
||||
# Check that find and ls-nar match.
|
||||
# Check that find and nar ls match.
|
||||
( cd $storePath; find . | sort ) > files.find
|
||||
nix ls-nar -R -d $narFile "" | sort > files.ls-nar
|
||||
nix nar ls -R -d $narFile "" | sort > files.ls-nar
|
||||
diff -u files.find files.ls-nar
|
||||
|
||||
# Check that file contents of data match.
|
||||
nix cat-nar $narFile /foo/data > data.cat-nar
|
||||
nix nar cat $narFile /foo/data > data.cat-nar
|
||||
diff -u data.cat-nar $storePath/foo/data
|
||||
|
||||
# Check that file contents of baz match.
|
||||
nix cat-nar $narFile /foo/baz > baz.cat-nar
|
||||
nix nar cat $narFile /foo/baz > baz.cat-nar
|
||||
diff -u baz.cat-nar $storePath/foo/baz
|
||||
|
||||
nix cat-store $storePath/foo/baz > baz.cat-nar
|
||||
nix store cat $storePath/foo/baz > baz.cat-nar
|
||||
diff -u baz.cat-nar $storePath/foo/baz
|
||||
|
||||
# Test --json.
|
||||
diff -u \
|
||||
<(nix ls-nar --json $narFile / | jq -S) \
|
||||
<(nix nar ls --json $narFile / | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"foo":{},"foo-x":{},"qux":{},"zyx":{}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-nar --json -R $narFile /foo | jq -S) \
|
||||
<(nix nar ls --json -R $narFile /foo | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"bar":{"type":"regular","size":0,"narOffset":368},"baz":{"type":"regular","size":0,"narOffset":552},"data":{"type":"regular","size":58,"narOffset":736}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-nar --json -R $narFile /foo/bar | jq -S) \
|
||||
<(nix nar ls --json -R $narFile /foo/bar | jq -S) \
|
||||
<(echo '{"type":"regular","size":0,"narOffset":368}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-store --json $storePath | jq -S) \
|
||||
<(nix store ls --json $storePath | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"foo":{},"foo-x":{},"qux":{},"zyx":{}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-store --json -R $storePath/foo | jq -S) \
|
||||
<(nix store ls --json -R $storePath/foo | jq -S) \
|
||||
<(echo '{"type":"directory","entries":{"bar":{"type":"regular","size":0},"baz":{"type":"regular","size":0},"data":{"type":"regular","size":58}}}' | jq -S)
|
||||
diff -u \
|
||||
<(nix ls-store --json -R $storePath/foo/bar| jq -S) \
|
||||
<(nix store ls --json -R $storePath/foo/bar| jq -S) \
|
||||
<(echo '{"type":"regular","size":0}' | jq -S)
|
||||
|
||||
# Test missing files.
|
||||
nix ls-store --json -R $storePath/xyzzy 2>&1 | grep 'does not exist in NAR'
|
||||
nix ls-store $storePath/xyzzy 2>&1 | grep 'does not exist'
|
||||
nix store ls --json -R $storePath/xyzzy 2>&1 | grep 'does not exist in NAR'
|
||||
nix store ls $storePath/xyzzy 2>&1 | grep 'does not exist'
|
||||
|
||||
# Test failure to dump.
|
||||
if nix-store --dump $storePath >/dev/full ; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue