summary refs log tree commit diff
path: root/src/libexpr/get-drvs.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-10-16 15:55:34 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-10-16 15:55:34 +0000
commitd7efd7639420f4c840cbfdfcbbb3c45292f3ac54 (patch)
treed48871893e6d3446b6298b0e5e612086233e3947 /src/libexpr/get-drvs.cc
parent4c9aa821b985b8e334790a03497a56af3a021f3b (diff)
downloadguix-d7efd7639420f4c840cbfdfcbbb3c45292f3ac54.tar.gz
* Big cleanup of the semantics of paths, strings, contexts, string
  concatenation and string coercion.  This was a big mess (see
  e.g. NIX-67).  Contexts are now folded into strings, so that they
  don't cause evaluation errors when they're not expected.  The
  semantics of paths has been clarified (see nixexpr-ast.def).
  toString() and coerceToString() have been merged.

  Semantic change: paths are now copied to the store when they're in a
  concatenation (and in most other situations - that's the
  formalisation of the meaning of a path).  So

    "foo " + ./bla

  evaluates to "foo /nix/store/hash...-bla", not "foo
  /path/to/current-dir/bla".  This prevents accidental impurities, and
  is more consistent with the treatment of derivation outputs, e.g.,
  `"foo " + bla' where `bla' is a derivation.  (Here `bla' would be
  replaced by the output path of `bla'.)

Diffstat (limited to 'src/libexpr/get-drvs.cc')
-rw-r--r--src/libexpr/get-drvs.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 808e12ffd5..acdc0c7b58 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -10,7 +10,8 @@ string DrvInfo::queryDrvPath(EvalState & state) const
 {
     if (drvPath == "") {
         Expr a = attrs->get(toATerm("drvPath"));
-        (string &) drvPath = a ? evalPath(state, a) : "";
+        PathSet context;
+        (string &) drvPath = a ? coerceToPath(state, a, context) : "";
     }
     return drvPath;
 }
@@ -21,7 +22,8 @@ string DrvInfo::queryOutPath(EvalState & state) const
     if (outPath == "") {
         Expr a = attrs->get(toATerm("outPath"));
         if (!a) throw TypeError("output path missing");
-        (string &) outPath = evalPath(state, a);
+        PathSet context;
+        (string &) outPath = coerceToPath(state, a, context);
     }
     return outPath;
 }
@@ -38,9 +40,11 @@ MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const
     queryAllAttrs(evalExpr(state, a), attrs2);
 
     for (ATermMap::const_iterator i = attrs2.begin(); i != attrs2.end(); ++i) {
-        ATerm s = coerceToString(evalExpr(state, i->value));
-        if (s)
-            meta[aterm2String(i->key)] = aterm2String(s);
+        Expr e = evalExpr(state, i->value);
+        string s;
+        PathSet context;
+        if (matchStr(e, s, context))
+            meta[aterm2String(i->key)] = s;
         /* For future compatibility, ignore attribute values that are
            not strings. */
     }
@@ -74,7 +78,7 @@ static bool getDerivation(EvalState & state, Expr e,
         queryAllAttrs(e, *attrs, false);
     
         Expr a = attrs->get(toATerm("type"));
-        if (!a || evalString(state, a) != "derivation") return true;
+        if (!a || evalStringNoCtx(state, a) != "derivation") return true;
 
         /* Remove spurious duplicates (e.g., an attribute set like
            `rec { x = derivation {...}; y = x;}'. */
@@ -86,13 +90,13 @@ static bool getDerivation(EvalState & state, Expr e,
         a = attrs->get(toATerm("name"));
         /* !!! We really would like to have a decent back trace here. */
         if (!a) throw TypeError("derivation name missing");
-        drv.name = evalString(state, a);
+        drv.name = evalStringNoCtx(state, a);
 
         a = attrs->get(toATerm("system"));
         if (!a)
             drv.system = "unknown";
         else
-            drv.system = evalString(state, a);
+            drv.system = evalStringNoCtx(state, a);
 
         drv.attrs = attrs;