mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
* 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'.)
This commit is contained in:
parent
4c9aa821b9
commit
d7efd76394
17 changed files with 331 additions and 396 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue