* 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
AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I..
@ -6,6 +6,9 @@ AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I..
nix_SOURCES = nix.cc shared.cc
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_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
path name for this package. */
ATerm nf = ATmake("Package(<term>)", ATreverse(bnds));
debug(printTerm(nf));
Hash hash = hashTerm(nf);
if (builder == "")
@ -202,7 +201,6 @@ static Expr evalExpr(Expr e)
/* Construct the result. */
e = ATmake("Derive(<str>, <str>, <term>, <str>, <term>)",
SYSTEM, builder.c_str(), ins, out.c_str(), env);
debug(printTerm(e));
/* Write the resulting term into the Nix store directory. */
Hash eHash = writeTerm(e);
@ -257,7 +255,7 @@ void run(Strings args)
char * s;
if (ATmatch(e, "Include(<str>)", &s)) {
cout << format("%1%\n") % s;
}
}
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";