* Get nix-env to compile.

This commit is contained in:
Eelco Dolstra 2010-03-31 19:12:08 +00:00
parent 55e207b2dc
commit d8cd3115d8
2 changed files with 38 additions and 38 deletions

View file

@ -17,14 +17,12 @@ string DrvInfo::queryDrvPath(EvalState & state) const
} }
#if 0
string DrvInfo::queryOutPath(EvalState & state) const string DrvInfo::queryOutPath(EvalState & state) const
{ {
if (outPath == "") { if (outPath == "") {
Expr a = attrs->get(toATerm("outPath")); Bindings::iterator i = attrs->find(toATerm("outPath"));
if (!a) throw TypeError("output path missing");
PathSet context; PathSet context;
(string &) outPath = coerceToPath(state, a, context); (string &) outPath = i != attrs->end() ? state.coerceToPath(i->second, context) : "";
} }
return outPath; return outPath;
} }
@ -34,33 +32,26 @@ MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const
{ {
MetaInfo meta; MetaInfo meta;
Expr a = attrs->get(toATerm("meta")); Bindings::iterator a = attrs->find(toATerm("meta"));
if (!a) return meta; /* fine, empty meta information */ if (a == attrs->end()) return meta; /* fine, empty meta information */
ATermMap attrs2; state.forceAttrs(a->second);
queryAllAttrs(evalExpr(state, a), attrs2);
for (ATermMap::const_iterator i = attrs2.begin(); i != attrs2.end(); ++i) { foreach (Bindings::iterator, i, *a->second.attrs) {
Expr e = evalExpr(state, i->value);
string s;
PathSet context;
MetaValue value; MetaValue value;
int n; state.forceValue(i->second);
ATermList es; if (i->second.type == tString) {
if (matchStr(e, s, context)) {
value.type = MetaValue::tpString; value.type = MetaValue::tpString;
value.stringValue = s; value.stringValue = i->second.string.s;
meta[aterm2String(i->key)] = value; } else if (i->second.type == tInt) {
} else if (matchInt(e, n)) {
value.type = MetaValue::tpInt; value.type = MetaValue::tpInt;
value.intValue = n; value.intValue = i->second.integer;
meta[aterm2String(i->key)] = value; } else if (i->second.type == tList) {
} else if (matchList(e, es)) {
value.type = MetaValue::tpStrings; value.type = MetaValue::tpStrings;
for (ATermIterator j(es); j; ++j) for (unsigned int j = 0; j < i->second.list.length; ++j)
value.stringValues.push_back(evalStringNoCtx(state, *j)); value.stringValues.push_back(state.forceStringNoCtx(i->second.list.elems[j]));
meta[aterm2String(i->key)] = value; } else continue;
} meta[aterm2String(i->first)] = value;
} }
return meta; return meta;
@ -76,6 +67,8 @@ MetaValue DrvInfo::queryMetaInfo(EvalState & state, const string & name) const
void DrvInfo::setMetaInfo(const MetaInfo & meta) void DrvInfo::setMetaInfo(const MetaInfo & meta)
{ {
throw Error("not implemented");
#if 0
ATermMap metaAttrs; ATermMap metaAttrs;
foreach (MetaInfo::const_iterator, i, meta) { foreach (MetaInfo::const_iterator, i, meta) {
Expr e; Expr e;
@ -94,8 +87,8 @@ void DrvInfo::setMetaInfo(const MetaInfo & meta)
metaAttrs.set(toATerm(i->first), makeAttrRHS(e, makeNoPos())); metaAttrs.set(toATerm(i->first), makeAttrRHS(e, makeNoPos()));
} }
attrs->set(toATerm("meta"), makeAttrs(metaAttrs)); attrs->set(toATerm("meta"), makeAttrs(metaAttrs));
}
#endif #endif
}
/* Cache for already considered values. */ /* Cache for already considered values. */

View file

@ -164,9 +164,12 @@ static void loadDerivations(EvalState & state, Path nixExprPath,
string systemFilter, const ATermMap & autoArgs, string systemFilter, const ATermMap & autoArgs,
const string & pathPrefix, DrvInfos & elems) const string & pathPrefix, DrvInfos & elems)
{ {
getDerivations(state, Value v;
findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath)), state.eval(loadSourceExpr(state, nixExprPath), v);
pathPrefix, autoArgs, elems);
// !!! findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath))
getDerivations(state, v, pathPrefix, autoArgs, elems);
/* Filter out all derivations not applicable to the current /* Filter out all derivations not applicable to the current
system. */ system. */
@ -221,7 +224,7 @@ static DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
e = bottomupRewrite(addPos, e); e = bottomupRewrite(addPos, e);
DrvInfos elems; DrvInfos elems;
getDerivations(state, e, "", ATermMap(1), elems); // !!! getDerivations(state, e, "", ATermMap(1), elems);
return elems; return elems;
} }
@ -255,6 +258,8 @@ static bool createUserEnv(EvalState & state, DrvInfos & elems,
const Path & profile, bool keepDerivations, const Path & profile, bool keepDerivations,
const string & lockToken) const string & lockToken)
{ {
throw Error("not implemented");
#if 0
/* Build the components in the user environment, if they don't /* Build the components in the user environment, if they don't
exist already. */ exist already. */
PathSet drvsToBuild; PathSet drvsToBuild;
@ -355,6 +360,7 @@ static bool createUserEnv(EvalState & state, DrvInfos & elems,
switchLink(profile, generation); switchLink(profile, generation);
return true; return true;
#endif
} }
@ -518,12 +524,11 @@ static void queryInstSources(EvalState & state,
Expr e1 = loadSourceExpr(state, instSource.nixExprPath); Expr e1 = loadSourceExpr(state, instSource.nixExprPath);
for (Strings::const_iterator i = args.begin(); foreach (Strings::const_iterator, i, args) {
i != args.end(); ++i)
{
Expr e2 = parseExprFromString(state, *i, absPath(".")); Expr e2 = parseExprFromString(state, *i, absPath("."));
Expr call = makeCall(e2, e1); Expr call = makeCall(e2, e1);
getDerivations(state, call, "", instSource.autoArgs, elems); Value v; state.eval(call, v);
getDerivations(state, v, "", instSource.autoArgs, elems);
} }
break; break;
@ -540,7 +545,7 @@ static void queryInstSources(EvalState & state,
Path path = followLinksToStorePath(*i); Path path = followLinksToStorePath(*i);
DrvInfo elem; DrvInfo elem;
elem.attrs = boost::shared_ptr<ATermMap>(new ATermMap(0)); /* ugh... */ elem.attrs = new Bindings;
string name = baseNameOf(path); string name = baseNameOf(path);
string::size_type dash = name.find('-'); string::size_type dash = name.find('-');
if (dash != string::npos) if (dash != string::npos)
@ -574,12 +579,14 @@ static void queryInstSources(EvalState & state,
} }
case srcAttrPath: { case srcAttrPath: {
for (Strings::const_iterator i = args.begin(); throw Error("not implemented");
i != args.end(); ++i) #if 0
foreach (Strings::const_iterator, i, args)
getDerivations(state, getDerivations(state,
findAlongAttrPath(state, *i, instSource.autoArgs, findAlongAttrPath(state, *i, instSource.autoArgs,
loadSourceExpr(state, instSource.nixExprPath)), loadSourceExpr(state, instSource.nixExprPath)),
"", instSource.autoArgs, elems); "", instSource.autoArgs, elems);
#endif
break; break;
} }
} }
@ -1472,7 +1479,7 @@ void run(Strings args)
op(globals, remaining, opFlags, opArgs); op(globals, remaining, opFlags, opArgs);
printEvalStats(globals.state); globals.state.printStats();
} }