1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 01:51:47 +02:00

Move 'nix hash-*' and 'nix to-*' to 'nix hash'

From the 'nix' UX review.
This commit is contained in:
Eelco Dolstra 2020-07-24 18:44:43 +02:00
parent 8ad2c9c4b9
commit b2d6c6161e
6 changed files with 51 additions and 27 deletions

View file

@ -12,7 +12,7 @@ cmp $outPath fetchurl.sh
# Now using a base-64 hash.
clearStore
hash=$(nix hash-file --type sha512 --base64 ./fetchurl.sh)
hash=$(nix hash file --type sha512 --base64 ./fetchurl.sh)
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh --argstr sha512 $hash --no-out-link)
@ -21,7 +21,7 @@ cmp $outPath fetchurl.sh
# Now using an SRI hash.
clearStore
hash=$(nix hash-file ./fetchurl.sh)
hash=$(nix hash file ./fetchurl.sh)
[[ $hash =~ ^sha256- ]]
@ -34,14 +34,14 @@ clearStore
other_store=file://$TEST_ROOT/other_store?store=/fnord/store
hash=$(nix hash-file --type sha256 --base16 ./fetchurl.sh)
hash=$(nix hash file --type sha256 --base16 ./fetchurl.sh)
storePath=$(nix --store $other_store add-to-store --flat ./fetchurl.sh)
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr sha256 $hash --no-out-link --substituters $other_store)
# Test hashed mirrors with an SRI hash.
nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr hash $(nix to-sri --type sha256 $hash) \
nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr hash $(nix hash to-sri --type sha256 $hash) \
--no-out-link --substituters $other_store
# Test unpacking a NAR.