about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am5
-rw-r--r--src/fix.cc4
-rw-r--r--src/nix-hash.cc16
3 files changed, 21 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7d12719ac4db..22b27d88a8a7 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 cb42aca6b773..33bcdd9a1372 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(<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);
     }
 }
diff --git a/src/nix-hash.cc b/src/nix-hash.cc
new file mode 100644
index 000000000000..e35d0a1feda3
--- /dev/null
+++ b/src/nix-hash.cc
@@ -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";
+