* Get nix-env to compile again.

This commit is contained in:
Eelco Dolstra 2010-04-14 09:39:06 +00:00
parent 85d13c8f93
commit 011b5da0f4

View file

@ -111,7 +111,7 @@ static bool isNixExpr(const Path & path)
static void getAllExprs(EvalState & state, static void getAllExprs(EvalState & state,
const Path & path, ATermMap & attrs) const Path & path, ExprAttrs & attrs)
{ {
Strings names = readDirectory(path); Strings names = readDirectory(path);
StringSet namesSorted(names.begin(), names.end()); StringSet namesSorted(names.begin(), names.end());
@ -131,8 +131,8 @@ static void getAllExprs(EvalState & state,
string attrName = *i; string attrName = *i;
if (hasSuffix(attrName, ".nix")) if (hasSuffix(attrName, ".nix"))
attrName = string(attrName, 0, attrName.size() - 4); attrName = string(attrName, 0, attrName.size() - 4);
attrs.set(toATerm(attrName), makeAttrRHS( attrs.attrs[state.symbols.create(attrName)] =
parseExprFromFile(state, absPath(path2)), makeNoPos())); parseExprFromFile(state, absPath(path2));
} }
else else
/* `path2' is a directory (with no default.nix in it); /* `path2' is a directory (with no default.nix in it);
@ -144,7 +144,7 @@ static void getAllExprs(EvalState & state,
static Expr * loadSourceExpr(EvalState & state, const Path & path) static Expr * loadSourceExpr(EvalState & state, const Path & path)
{ {
if (isNixExpr(path)) return parseExprFromFile(absPath(path)); if (isNixExpr(path)) return parseExprFromFile(state, absPath(path));
/* The path is a directory. Put the Nix expressions in the /* The path is a directory. Put the Nix expressions in the
directory in an attribute set, with the file name of each directory in an attribute set, with the file name of each
@ -152,10 +152,10 @@ static Expr * loadSourceExpr(EvalState & state, const Path & path)
(but keep the attribute set flat, not nested, to make it easier (but keep the attribute set flat, not nested, to make it easier
for a user to have a ~/.nix-defexpr directory that includes for a user to have a ~/.nix-defexpr directory that includes
some system-wide directory). */ some system-wide directory). */
ATermMap attrs; ExprAttrs * attrs = new ExprAttrs;
attrs.set(toATerm("_combineChannels"), makeAttrRHS(makeList(ATempty), makeNoPos())); attrs->attrs[state.symbols.create("_combineChannels")] = new ExprInt(1);
getAllExprs(state, path, attrs); getAllExprs(state, path, *attrs);
return makeAttrs(attrs); return attrs;
} }
@ -192,20 +192,6 @@ static Path getDefNixExprPath()
} }
struct AddPos : TermFun
{
ATerm operator () (ATerm e)
{
ATerm x, y;
if (matchObsoleteBind(e, x, y))
return makeBind(x, y, makeNoPos());
if (matchObsoleteStr(e, x))
return makeStr(x, ATempty);
return e;
}
};
static DrvInfos queryInstalled(EvalState & state, const Path & userEnv) static DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
{ {
Path path = userEnv + "/manifest"; Path path = userEnv + "/manifest";
@ -213,16 +199,15 @@ static DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
if (!pathExists(path)) if (!pathExists(path))
return DrvInfos(); /* not an error, assume nothing installed */ return DrvInfos(); /* not an error, assume nothing installed */
throw Error("not implemented");
#if 0
Expr e = ATreadFromNamedFile(path.c_str()); Expr e = ATreadFromNamedFile(path.c_str());
if (!e) throw Error(format("cannot read Nix expression from `%1%'") % path); if (!e) throw Error(format("cannot read Nix expression from `%1%'") % path);
/* Compatibility: Bind(x, y) -> Bind(x, y, NoPos). */
AddPos addPos;
e = bottomupRewrite(addPos, e);
DrvInfos elems; DrvInfos elems;
// !!! getDerivations(state, e, "", ATermMap(1), elems); // !!! getDerivations(state, e, "", ATermMap(1), elems);
return elems; return elems;
#endif
} }
@ -519,11 +504,11 @@ static void queryInstSources(EvalState & state,
(import ./foo.nix)' = `(import ./foo.nix).bar'. */ (import ./foo.nix)' = `(import ./foo.nix).bar'. */
case srcNixExprs: { case srcNixExprs: {
Expr e1 = loadSourceExpr(state, instSource.nixExprPath); Expr * e1 = loadSourceExpr(state, instSource.nixExprPath);
foreach (Strings::const_iterator, i, args) { foreach (Strings::const_iterator, i, args) {
Expr e2 = parseExprFromString(state, *i, absPath(".")); Expr * e2 = parseExprFromString(state, *i, absPath("."));
Expr call = makeCall(e2, e1); Expr * call = new ExprApp(e2, e1);
Value v; state.eval(call, v); Value v; state.eval(call, v);
getDerivations(state, v, "", instSource.autoArgs, elems); getDerivations(state, v, "", instSource.autoArgs, elems);
} }