* A utility `nix-hash' to compute Nix path hashes.

This commit is contained in:
Eelco Dolstra 2003-07-06 15:11:02 +00:00
parent bfa5d77211
commit 7952a8053c
3 changed files with 21 additions and 4 deletions

View file

@ -1,4 +1,4 @@
bin_PROGRAMS = nix fix bin_PROGRAMS = nix nix-hash fix
check_PROGRAMS = test check_PROGRAMS = test
AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I.. AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I..
@ -6,6 +6,9 @@ AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I..
nix_SOURCES = nix.cc shared.cc nix_SOURCES = nix.cc shared.cc
nix_LDADD = libnix.a -ldb_cxx-4 -lATerm nix_LDADD = libnix.a -ldb_cxx-4 -lATerm
nix_hash_SOURCES = nix-hash.cc shared.cc
nix_hash_LDADD = libnix.a -ldb_cxx-4 -lATerm
fix_SOURCES = fix.cc shared.cc fix_SOURCES = fix.cc shared.cc
fix_LDADD = libnix.a -ldb_cxx-4 -lATerm fix_LDADD = libnix.a -ldb_cxx-4 -lATerm

View file

@ -186,7 +186,6 @@ static Expr evalExpr(Expr e)
/* Hash the normal form to produce a unique but deterministic /* Hash the normal form to produce a unique but deterministic
path name for this package. */ path name for this package. */
ATerm nf = ATmake("Package(<term>)", ATreverse(bnds)); ATerm nf = ATmake("Package(<term>)", ATreverse(bnds));
debug(printTerm(nf));
Hash hash = hashTerm(nf); Hash hash = hashTerm(nf);
if (builder == "") if (builder == "")
@ -202,7 +201,6 @@ static Expr evalExpr(Expr e)
/* Construct the result. */ /* Construct the result. */
e = ATmake("Derive(<str>, <str>, <term>, <str>, <term>)", e = ATmake("Derive(<str>, <str>, <term>, <str>, <term>)",
SYSTEM, builder.c_str(), ins, out.c_str(), env); SYSTEM, builder.c_str(), ins, out.c_str(), env);
debug(printTerm(e));
/* Write the resulting term into the Nix store directory. */ /* Write the resulting term into the Nix store directory. */
Hash eHash = writeTerm(e); Hash eHash = writeTerm(e);
@ -257,7 +255,7 @@ void run(Strings args)
char * s; char * s;
if (ATmatch(e, "Include(<str>)", &s)) { if (ATmatch(e, "Include(<str>)", &s)) {
cout << format("%1%\n") % s; cout << format("%1%\n") % s;
} }
else throw badTerm("top level is not a package", e); else throw badTerm("top level is not a package", e);
} }
} }

16
src/nix-hash.cc Normal file
View file

@ -0,0 +1,16 @@
#include <iostream>
#include "hash.hh"
#include "shared.hh"
void run(Strings args)
{
for (Strings::iterator it = args.begin();
it != args.end(); it++)
cout << format("%1%\n") % (string) hashPath(*it);
}
string programId = "nix-hash";