about summary refs log tree commit diff
path: root/src/nix-env
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-05-09T17·55+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-05-09T17·55+0000
commit9ec7e58aa44d413df071a07aae45e4c32b331274 (patch)
tree9d70d35cccdfb2cacccbc5f29cf535dd60753848 /src/nix-env
parentbfe4875a5e1058462345cd791061a332e510e033 (diff)
* Handle store path arguments in `nix-env -i' correctly again.
Diffstat (limited to 'src/nix-env')
-rw-r--r--src/nix-env/main.cc39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc
index 6ff80992c39e..4676f0131ab0 100644
--- a/src/nix-env/main.cc
+++ b/src/nix-env/main.cc
@@ -49,22 +49,43 @@ typedef void (* Operation) (Globals & globals,
 
 struct UserEnvElem
 {
+private:
+    string drvPath;
+    string outPath;
+    
+public:
     string name;
     string system;
 
     ATermMap attrs;
 
-    string queryDrvPath(EvalState & state) const 
+    string queryDrvPath(EvalState & state) const
     {
-        Expr a = attrs.get("drvPath");
-        return a ? evalPath(state, a) : "";
+        if (drvPath == "") {
+            Expr a = attrs.get("drvPath");
+            (string &) drvPath = a ? evalPath(state, a) : "";
+        }
+        return drvPath;
     }
     
     string queryOutPath(EvalState & state) const
     {
-        Expr a = attrs.get("outPath");
-        if (!a) throw Error("output path missing");
-        return evalPath(state, a);
+        if (outPath == "") {
+            Expr a = attrs.get("outPath");
+            if (!a) throw Error("output path missing");
+            (string &) outPath = evalPath(state, a);
+        }
+        return outPath;
+    }
+
+    void setDrvPath(const string & s)
+    {
+        drvPath = s;
+    }
+    
+    void setOutPath(const string & s)
+    {
+        outPath = s;
     }
 };
 
@@ -394,13 +415,13 @@ static void queryInstSources(EvalState & state,
                     name = string(name, dash + 1);
 
                 if (isDerivation(*i)) {
-                    elem.queryDrvPath(state) = *i;
-                    elem.queryOutPath(state) = findOutput(derivationFromPath(*i), "out");
+                    elem.setDrvPath(*i);
+                    elem.setOutPath(findOutput(derivationFromPath(*i), "out"));
                     if (name.size() >= drvExtension.size() &&
                         string(name, name.size() - drvExtension.size()) == drvExtension)
                         name = string(name, 0, name.size() - drvExtension.size());
                 }
-                else elem.queryOutPath(state) = *i;
+                else elem.setOutPath(*i);
 
                 elem.name = name;