forked from lix-project/lix
* New builtin function "isFunction". You're not supposed to use it
;-) * Channels: fix channels that are plain lists of derivations (like strategoxt-unstable) instead of functions (like nixpkgs-unstable). This fixes the error message "error: the left-hand side of the function call is neither a function nor a primop (built-in operation) but a list".
This commit is contained in:
parent
ca00aa1171
commit
bddc83a148
|
@ -24,7 +24,7 @@ for ((n = 0; n < ${#inputs[*]}; n += 2)); do
|
||||||
@coreutils@/mv * ../$dirName # !!! hacky
|
@coreutils@/mv * ../$dirName # !!! hacky
|
||||||
|
|
||||||
attrName=$(echo $dirName | @tr@ -- '- ' '__')
|
attrName=$(echo $dirName | @tr@ -- '- ' '__')
|
||||||
echo "$attrName = import ./$dirName {};" >> $expr
|
echo "$attrName = let e = import ./$dirName; in if builtins.isFunction e then e {} else e;" >> $expr
|
||||||
done
|
done
|
||||||
|
|
||||||
echo '} // {_combineChannels = true;}' >> $expr
|
echo '} // {_combineChannels = true;}' >> $expr
|
||||||
|
|
|
@ -478,7 +478,7 @@ LocalNoInline(Expr evalCall(EvalState & state, Expr fun, Expr arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
else throwTypeError(
|
else throwTypeError(
|
||||||
"the left-hand side of the function call is neither a function nor a primop (built-in operation) but %1%",
|
"attempt to call something which is neither a function nor a primop (built-in operation) but %1%",
|
||||||
showType(fun));
|
showType(fun));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,18 @@ static Expr prim_isNull(EvalState & state, const ATermVector & args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Determine whether the argument is a function. */
|
||||||
|
static Expr prim_isFunction(EvalState & state, const ATermVector & args)
|
||||||
|
{
|
||||||
|
Expr e = evalExpr(state, args[0]);
|
||||||
|
ATermList formals;
|
||||||
|
ATerm name, body, pos;
|
||||||
|
return makeBool(
|
||||||
|
matchFunction(e, formals, body, pos) ||
|
||||||
|
matchFunction1(e, name, body, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Path findDependency(Path dir, string dep)
|
static Path findDependency(Path dir, string dep)
|
||||||
{
|
{
|
||||||
if (dep[0] == '/') throw EvalError(
|
if (dep[0] == '/') throw EvalError(
|
||||||
|
@ -884,6 +896,7 @@ void EvalState::addPrimOps()
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
addPrimOp("import", 1, prim_import);
|
addPrimOp("import", 1, prim_import);
|
||||||
addPrimOp("isNull", 1, prim_isNull);
|
addPrimOp("isNull", 1, prim_isNull);
|
||||||
|
addPrimOp("__isFunction", 1, prim_isFunction);
|
||||||
addPrimOp("dependencyClosure", 1, prim_dependencyClosure);
|
addPrimOp("dependencyClosure", 1, prim_dependencyClosure);
|
||||||
addPrimOp("abort", 1, prim_abort);
|
addPrimOp("abort", 1, prim_abort);
|
||||||
addPrimOp("throw", 1, prim_throw);
|
addPrimOp("throw", 1, prim_throw);
|
||||||
|
|
Loading…
Reference in a new issue