about summary refs log tree commit diff
path: root/src/nix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-10T13·41+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-10T13·41+0000
commitd072485d2895d01dbbab1d899418726e3349343f (patch)
tree237c23cdb613d363e9205f89d51cac8433cf3b85 /src/nix.cc
parent5d4b90b689b09965be39c69aceddaf0b165598d0 (diff)
* Get `nix-push' working again. It now uses Nix/Fix to create Nix
  archives (using the package in corepkgs/nar).
* queryPathByHash -> expandHash, and it takes an argument specifying
  the target path (which may be empty).
* Install the core Fix packages in $prefix/share/fix.  TODO: bootstrap
  Nix and install Nix as a Fix package.

Diffstat (limited to 'src/nix.cc')
-rw-r--r--src/nix.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/nix.cc b/src/nix.cc
index d6f2db4fefd1..4721563fdff5 100644
--- a/src/nix.cc
+++ b/src/nix.cc
@@ -37,7 +37,7 @@ static ArgType argType = atpUnknown;
 
    Source selection for --install, --dump:
 
-     --file / -f: by file name
+     --file / -f: by file name  !!! -> path
      --hash / -h: by hash
 
    Query flags:
@@ -87,6 +87,12 @@ static Hash argToHash(const string & arg)
 }
 
 
+static FState hash2fstate(Hash hash)
+{
+    return ATmake("Include(<str>)", ((string) hash).c_str());
+}
+
+
 /* Realise (or install) paths from the given Nix fstate
    expressions. */
 static void opInstall(Strings opFlags, Strings opArgs)
@@ -98,7 +104,7 @@ static void opInstall(Strings opFlags, Strings opArgs)
          it != opArgs.end(); it++)
     {
         StringSet paths;
-        realiseFState(termFromHash(argToHash(*it)), paths);
+        realiseFState(hash2fstate(argToHash(*it)), paths);
     }
 }
 
@@ -157,14 +163,16 @@ static void opQuery(Strings opFlags, Strings opArgs)
 
         switch (query) {
 
-        case qPath:
+        case qPath: {
+            StringSet refs;
             cout << format("%s\n") % 
-                (string) fstatePath(termFromHash(hash));
+                (string) fstatePath(realiseFState(termFromHash(hash), refs));
             break;
+        }
 
         case qRefs: {
             StringSet refs;
-            FState fs = ATmake("Include(<str>)", ((string) hash).c_str());
+            FState fs = hash2fstate(hash);
             fstateRefs(realiseFState(fs, refs), refs);
             for (StringSet::iterator j = refs.begin(); 
                  j != refs.end(); j++)
@@ -203,10 +211,8 @@ static void opDump(Strings opFlags, Strings opArgs)
     string arg = *opArgs.begin();
     string path;
     
-    if (argType == atpHash)
-        path = queryPathByHash(parseHash(arg));
-    else if (argType == atpPath)
-        path = arg;
+    if (argType == atpHash) path = expandHash(parseHash(arg));
+    else if (argType == atpPath) path = arg;
 
     dumpPath(path, sink);
 }