Add option type for a submodule with extra arguments
This commit is contained in:
parent
ca1c5cfa8f
commit
8764758044
|
@ -176,7 +176,7 @@ rec {
|
||||||
getSubOptions = elemType.getSubOptions;
|
getSubOptions = elemType.getSubOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
submodule = opts:
|
submoduleWithExtraArgs = extraArgs: opts:
|
||||||
let
|
let
|
||||||
opts' = toList opts;
|
opts' = toList opts;
|
||||||
inherit (import ./modules.nix) evalModules;
|
inherit (import ./modules.nix) evalModules;
|
||||||
|
@ -188,13 +188,16 @@ rec {
|
||||||
let
|
let
|
||||||
coerce = def: if isFunction def then def else { config = def; };
|
coerce = def: if isFunction def then def else { config = def; };
|
||||||
modules = opts' ++ map (def: { _file = def.file; imports = [(coerce def.value)]; }) defs;
|
modules = opts' ++ map (def: { _file = def.file; imports = [(coerce def.value)]; }) defs;
|
||||||
in (evalModules { inherit modules; args.name = last loc; prefix = loc; }).config;
|
args = extraArgs // { name = last loc; };
|
||||||
|
in (evalModules { inherit modules args; prefix = loc; }).config;
|
||||||
getSubOptions = prefix: (evalModules
|
getSubOptions = prefix: (evalModules
|
||||||
{ modules = opts'; inherit prefix;
|
{ modules = opts'; inherit prefix;
|
||||||
# FIXME: hack to get shit to evaluate.
|
# FIXME: hack to get shit to evaluate.
|
||||||
args = { name = ""; }; }).options;
|
args = extraArgs // { name = ""; }; }).options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
submodule = submoduleWithExtraArgs {};
|
||||||
|
|
||||||
nixosSubmodule = nixos: args: mkOptionType rec {
|
nixosSubmodule = nixos: args: mkOptionType rec {
|
||||||
name = "submodule containing a NixOS config";
|
name = "submodule containing a NixOS config";
|
||||||
check = x: isAttrs x || isFunction x;
|
check = x: isAttrs x || isFunction x;
|
||||||
|
|
Loading…
Reference in New Issue