3
0
Fork 0
forked from mirrors/nixpkgs

Add support for require attribute with a filename as argument.

svn path=/nixpkgs/trunk/; revision=15657
This commit is contained in:
Nicolas Pierron 2009-05-19 23:06:56 +00:00
parent 5fff65dce9
commit 36dcabd7be

View file

@ -136,6 +136,16 @@ rec {
notHandle = opts: {}; notHandle = opts: {};
}; };
# Unfortunately this can also be a string.
isPath = x: !(
builtins.isFunction x
|| builtins.isAttrs x
|| builtins.isInt x
|| builtins.isBool x
|| builtins.isList x
);
# Evaluate a list of option sets that would be merged with the # Evaluate a list of option sets that would be merged with the
# function "merge" which expects two arguments. The attribute named # function "merge" which expects two arguments. The attribute named
# "require" is used to imports option declarations and bindings. # "require" is used to imports option declarations and bindings.
@ -157,6 +167,10 @@ rec {
else else
cfgSet1; cfgSet1;
filenameHandler = cfg:
if isPath cfg then import cfg
else cfg;
# call configuration "files" with one of the existing convention. # call configuration "files" with one of the existing convention.
argumentHandler = cfg: argumentHandler = cfg:
let let
@ -173,9 +187,10 @@ rec {
else cfg0; else cfg0;
preprocess = cfg0: preprocess = cfg0:
let cfg1 = argumentHandler cfg0; let cfg1 = filenameHandler cfg0;
cfg2 = noImportConditions cfg1; cfg2 = argumentHandler cfg1;
in cfg2; cfg3 = noImportConditions cfg2;
in cfg3;
getRequire = x: getRequire = x:
toList (getAttr ["require"] [] (preprocess x)); toList (getAttr ["require"] [] (preprocess x));