From 84e6c43e85cab83ee033bf13c1e58c0f30ca1de9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 2 Oct 2006 22:11:44 +0000 Subject: * Documented nix-hash. --- doc/manual/Makefile.am | 2 +- doc/manual/manual.xml | 4 + doc/manual/nix-hash.xml | 153 +++++++++++++++++++++++++++++++++++++ doc/manual/nix-install-package.xml | 3 - doc/manual/nix-store.xml | 3 + 5 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 doc/manual/nix-hash.xml (limited to 'doc/manual') diff --git a/doc/manual/Makefile.am b/doc/manual/Makefile.am index ea8cb3e9ad23..1e490e8ffcd1 100644 --- a/doc/manual/Makefile.am +++ b/doc/manual/Makefile.am @@ -11,7 +11,7 @@ man1_MANS = nix-env.1 nix-build.1 nix-store.1 nix-instantiate.1 \ nix-collect-garbage.1 nix-push.1 nix-pull.1 \ nix-prefetch-url.1 nix-channel.1 \ nix-pack-closure.1 nix-unpack-closure.1 \ - nix-install-package.1 + nix-install-package.1 nix-hash.1 FIGURES = figures/user-environments.png diff --git a/doc/manual/manual.xml b/doc/manual/manual.xml index db9e77c6b588..d8fd5ddb210a 100644 --- a/doc/manual/manual.xml +++ b/doc/manual/manual.xml @@ -69,6 +69,10 @@ nix-collect-garbage +
+ nix-hash + +
nix-install-package diff --git a/doc/manual/nix-hash.xml b/doc/manual/nix-hash.xml new file mode 100644 index 000000000000..3a28fe4c6b64 --- /dev/null +++ b/doc/manual/nix-hash.xml @@ -0,0 +1,153 @@ + + + + nix-hash + compute the cryptographic hash of a path + + + + + nix-hash + + + + hashAlgo + path + + + nix-hash + + hash + + + nix-hash + + hash + + + + +Description + +The command nix-hash computes the +cryptographic hash of the contents of each +path and prints it on standard output. By +default, it computes an MD5 hash, but other hash algorithms are +available as well. The hash is printed in hexadecimal. + +The hash is computed over a serialisation +of each path: a dump of the file system tree rooted at the path. This +allows directories and symlinks to be hashed as well as regular files. +The dump is in the NAR format produced by +nix-store . Thus, +nix-hash path yields the +same cryptographic hash as nix-store --dump +path | md5sum. + + + + +Options + + + + + + Print the cryptographic hash of the contents of + each regular file path. That is, do + not compute the hash over the dump of + path. The result is identical to that + produced by the GNU commands md5sum and + sha1sum. + + + + + + Print the hash in a base-32 representation rather + than hexadecimal. This base-32 representation is more compact and + can be used in Nix expressions (such as in calls to + fetchurl). + + + + + + Truncate hashes longer than 160 bits (such as + SHA-256) to 160 bits. + + + + hashAlgo + + Specify a cryptographic hash, which can be one of + md5, sha1, and + sha256. + + + + + + Don’t hash anything, but convert the base-32 hash + representation hash to + hexadecimal. + + + + + + Don’t hash anything, but convert the hexadecimal + hash representation hash to + base-32. + + + + + + + + +Examples + +Computing hashes: + + +$ mkdir test +$ echo "hello" > test/world + +$ nix-hash test/ (MD5 hash; default) +8179d3caeff1869b5ba1744e5a245c04 + +$ nix-store --dump test/ | md5sum (for comparison) +8179d3caeff1869b5ba1744e5a245c04 - + +$ nix-hash --type sha1 test/ +e4fd8ba5f7bbeaea5ace89fe10255536cd60dab6 + +$ nix-hash --type sha1 --base32 test/ +nvd61k9nalji1zl9rrdfmsmvyyjqpzg4 + +$ nix-hash --type sha256 --flat test/ +error: reading file `test/': Is a directory + +$ nix-hash --type sha256 --flat test/world +5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03 + + + +Converting between hexadecimal and base-32: + + +$ nix-hash --type sha1 --to-base32 e4fd8ba5f7bbeaea5ace89fe10255536cd60dab6 +nvd61k9nalji1zl9rrdfmsmvyyjqpzg4 + +$ nix-hash --type sha1 --to-base16 nvd61k9nalji1zl9rrdfmsmvyyjqpzg4 +e4fd8ba5f7bbeaea5ace89fe10255536cd60dab6 + + + + + + + diff --git a/doc/manual/nix-install-package.xml b/doc/manual/nix-install-package.xml index b696fa03fcc9..5e4f03d73429 100644 --- a/doc/manual/nix-install-package.xml +++ b/doc/manual/nix-install-package.xml @@ -86,11 +86,8 @@ to restart itself with xterm, - Examples - - To install subversion-1.4.0.nixpkg into the user’s current profile, without any prompting: diff --git a/doc/manual/nix-store.xml b/doc/manual/nix-store.xml index b8ee297242d9..41257e3ded39 100644 --- a/doc/manual/nix-store.xml +++ b/doc/manual/nix-store.xml @@ -670,8 +670,11 @@ in Nix itself. + + + -- cgit 1.4.1