about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-10-25T14·38+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-10-25T14·38+0000
commitf4d44a002688262d33093494a7fea1bb11b97ac9 (patch)
tree9768179865220106bd1c0103361ded0967c059c8 /src/libexpr
parent3ade3e7721df981614bbb2420baeb84e58085967 (diff)
* Allow certain operations to succeed even if we don't have write
  permission to the Nix store or database.  E.g., `nix-env -qa' will
  work, but `nix-env -qas' won't (the latter needs DB access).  The
  option `--readonly-mode' forces this mode; otherwise, it's only
  activated when the database cannot be opened.

Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.hh4
-rw-r--r--src/libexpr/primops.cc16
2 files changed, 14 insertions, 6 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index b51a5b0798..8ea0aec06c 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -8,7 +8,7 @@
 #include "nixexpr.hh"
 
 
-typedef map<Path, PathSet> DrvPaths;
+typedef map<Path, PathSet> DrvRoots;
 typedef map<Path, Hash> DrvHashes;
 
 struct EvalState;
@@ -22,7 +22,7 @@ struct EvalState
 {
     ATermMap normalForms;
     ATermMap primOps;
-    DrvPaths drvPaths;
+    DrvRoots drvRoots;
     DrvHashes drvHashes; /* normalised derivation hashes */
     Expr blackHole;
 
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 6588922c26..070ed1b54a 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -17,12 +17,12 @@ static Expr primImport(EvalState & state, const ATermVector & args)
 
 static PathSet storeExprRootsCached(EvalState & state, const Path & nePath)
 {
-    DrvPaths::iterator i = state.drvPaths.find(nePath);
-    if (i != state.drvPaths.end())
+    DrvRoots::iterator i = state.drvRoots.find(nePath);
+    if (i != state.drvRoots.end())
         return i->second;
     else {
         PathSet paths = storeExprRoots(nePath);
-        state.drvPaths[nePath] = paths;
+        state.drvRoots[nePath] = paths;
         return paths;
     }
 }
@@ -61,6 +61,8 @@ static Path copyAtom(EvalState & state, const Path & srcPath)
     Path drvPath = writeTerm(unparseStoreExpr(ne), "");
     state.drvHashes[drvPath] = drvHash;
 
+    state.drvRoots[drvPath] = ne.closure.roots;
+
     printMsg(lvlChatty, format("copied `%1%' -> closure `%2%'")
         % srcPath % drvPath);
     return drvPath;
@@ -111,8 +113,14 @@ static void processBinding(EvalState & state, Expr e, StoreExpr & ne,
             if (!a) throw Error("derivation hash missing");
             Hash drvHash = parseHash(evalString(state, a));
 
-            state.drvHashes[drvPath] = drvHash;
+            a = queryAttr(e, "outPath");
+            if (!a) throw Error("output path missing");
+            PathSet drvRoots;
+            drvRoots.insert(evalPath(state, a));
             
+            state.drvHashes[drvPath] = drvHash;
+            state.drvRoots[drvPath] = drvRoots;
+
             ss.push_back(addInput(state, drvPath, ne));
         } else
             throw Error("invalid derivation attribute");