summaryrefslogtreecommitdiffstats
path: root/lib/types.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-02-11 14:39:46 -0500
committerShea Levy <shea@shealevy.com>2014-02-11 14:39:46 -0500
commit8764758044b0425de54228d87cc68a4ed6d4d414 (patch)
treeddd80a68433ae15fed4390b6d75dfc7cd30a3505 /lib/types.nix
parentca1c5cfa8fff055c74786dbe0d2ca889ae462365 (diff)
Add option type for a submodule with extra arguments
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/types.nix b/lib/types.nix
index ac84ef296110..77957a7763ba 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -176,7 +176,7 @@ rec {
getSubOptions = elemType.getSubOptions;
};
- submodule = opts:
+ submoduleWithExtraArgs = extraArgs: opts:
let
opts' = toList opts;
inherit (import ./modules.nix) evalModules;
@@ -188,13 +188,16 @@ rec {
let
coerce = def: if isFunction def then def else { config = def; };
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
{ modules = opts'; inherit prefix;
# FIXME: hack to get shit to evaluate.
- args = { name = ""; }; }).options;
+ args = extraArgs // { name = ""; }; }).options;
};
+ submodule = submoduleWithExtraArgs {};
+
nixosSubmodule = nixos: args: mkOptionType rec {
name = "submodule containing a NixOS config";
check = x: isAttrs x || isFunction x;