diff --git a/src/Makefile.am b/src/Makefile.am index 7d12719ac4..22b27d88a8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/fix.cc b/src/fix.cc index cb42aca6b7..33bcdd9a13 100644 --- a/src/fix.cc +++ b/src/fix.cc @@ -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()", 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(, , , , )", 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()", &s)) { cout << format("%1%\n") % s; - } + } else throw badTerm("top level is not a package", e); } } diff --git a/src/nix-hash.cc b/src/nix-hash.cc new file mode 100644 index 0000000000..e35d0a1fed --- /dev/null +++ b/src/nix-hash.cc @@ -0,0 +1,16 @@ +#include + +#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"; +