mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 23:02:27 +00:00
3811b334c6
The old syntax is still supported, as long as you don't use a { in the description - the reason to migrate.
2.0 KiB
2.0 KiB
synopsis | prs |
---|---|
Add `nix hash convert` | 9452 |
New nix hash convert
sub command with a fast track
to stabilization! Examples:
-
Convert the hash to
nix32
.$ nix hash convert --algo "sha1" --to nix32 "800d59cfcd3c05e900cb4e214be48f6b886a08df" vw46m23bizj4n8afrc0fj19wrp7mj3c0
nix32
is a base32 encoding with a nix-specific character set. Explicitly specify the hashing algorithm (optional with SRI hashes) but detect hash format by the length of the input hash. -
Convert the hash to the
sri
format that includes an algorithm specification:nix hash convert --algo "sha1" "800d59cfcd3c05e900cb4e214be48f6b886a08df" sha1-gA1Zz808BekAy04hS+SPa4hqCN8=
or with an explicit
-to
format:nix hash convert --algo "sha1" --to sri "800d59cfcd3c05e900cb4e214be48f6b886a08df" sha1-gA1Zz808BekAy04hS+SPa4hqCN8=
-
Assert the input format of the hash:
nix hash convert --algo "sha256" --from nix32 "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=" error: input hash 'ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=' does not have the expected format '--from nix32' nix hash convert --algo "sha256" --from nix32 "1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s" sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=
The --to
/--from
/--algo
parameters have context-sensitive auto-completion.
Related Deprecations
The following commands are still available but will emit a deprecation warning. Please convert your code to
nix hash convert
:
nix hash to-base16 $hash1 $hash2
: Usenix hash convert --to base16 $hash1 $hash2
instead.nix hash to-base32 $hash1 $hash2
: Usenix hash convert --to nix32 $hash1 $hash2
instead.nix hash to-base64 $hash1 $hash2
: Usenix hash convert --to base64 $hash1 $hash2
instead.nix hash to-sri $hash1 $hash2
: : Usenix hash convert --to sri $hash1 $hash2
or even justnix hash convert $hash1 $hash2
instead.