mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-30 22:21:26 +00:00
Add support for require attribute with a filename as argument.
svn path=/nixpkgs/trunk/; revision=15657
This commit is contained in:
parent
5fff65dce9
commit
36dcabd7be
@ -136,6 +136,16 @@ rec {
|
||||
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
|
||||
# function "merge" which expects two arguments. The attribute named
|
||||
# "require" is used to imports option declarations and bindings.
|
||||
@ -157,6 +167,10 @@ rec {
|
||||
else
|
||||
cfgSet1;
|
||||
|
||||
filenameHandler = cfg:
|
||||
if isPath cfg then import cfg
|
||||
else cfg;
|
||||
|
||||
# call configuration "files" with one of the existing convention.
|
||||
argumentHandler = cfg:
|
||||
let
|
||||
@ -173,9 +187,10 @@ rec {
|
||||
else cfg0;
|
||||
|
||||
preprocess = cfg0:
|
||||
let cfg1 = argumentHandler cfg0;
|
||||
cfg2 = noImportConditions cfg1;
|
||||
in cfg2;
|
||||
let cfg1 = filenameHandler cfg0;
|
||||
cfg2 = argumentHandler cfg1;
|
||||
cfg3 = noImportConditions cfg2;
|
||||
in cfg3;
|
||||
|
||||
getRequire = x:
|
||||
toList (getAttr ["require"] [] (preprocess x));
|
||||
|
Loading…
Reference in New Issue
Block a user