mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-09-29 15:43:00 +00:00
Allow imports in plain modules
This commit is contained in:
parent
1e24ce2a9b
commit
1367074940
@ -36,7 +36,7 @@ rec {
|
|||||||
/* Massage a module into canonical form, that is, a set consisting
|
/* Massage a module into canonical form, that is, a set consisting
|
||||||
of ‘options’, ‘config’ and ‘imports’ attributes. */
|
of ‘options’, ‘config’ and ‘imports’ attributes. */
|
||||||
unifyModuleSyntax = file: key: m:
|
unifyModuleSyntax = file: key: m:
|
||||||
if m ? config || m ? options || m ? imports then
|
if m ? config || m ? options then
|
||||||
let badAttrs = removeAttrs m ["imports" "options" "config" "key"]; in
|
let badAttrs = removeAttrs m ["imports" "options" "config" "key"]; in
|
||||||
if badAttrs != {} then
|
if badAttrs != {} then
|
||||||
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'."
|
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'."
|
||||||
@ -50,9 +50,9 @@ rec {
|
|||||||
else
|
else
|
||||||
{ inherit file;
|
{ inherit file;
|
||||||
key = m.key or key;
|
key = m.key or key;
|
||||||
imports = m.require or [];
|
imports = m.require or [] ++ m.imports or [];
|
||||||
options = {};
|
options = {};
|
||||||
config = removeAttrs m ["key" "require"];
|
config = removeAttrs m ["key" "require" "imports"];
|
||||||
};
|
};
|
||||||
|
|
||||||
applyIfFunction = f: arg: if builtins.isFunction f then f arg else f;
|
applyIfFunction = f: arg: if builtins.isFunction f then f arg else f;
|
||||||
|
Loading…
Reference in New Issue
Block a user