summaryrefslogtreecommitdiffstats
path: root/lib/types.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-02-11 14:21:34 -0500
committerShea Levy <shea@shealevy.com>2014-02-11 14:21:34 -0500
commitca1c5cfa8fff055c74786dbe0d2ca889ae462365 (patch)
treefd4ce920309cfe522f380edbdae715648388cb30 /lib/types.nix
parent2deb26bd4a0c21d7c5eef54cdd2f4913699efb7c (diff)
Add nixosSubmodule option type
Since NixOS modules expect special arguments, use a hack to provide them
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix
index afc8f80eb0ea..ac84ef296110 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -195,6 +195,25 @@ rec {
args = { name = ""; }; }).options;
};
+ nixosSubmodule = nixos: args: mkOptionType rec {
+ name = "submodule containing a NixOS config";
+ check = x: isAttrs x || isFunction x;
+ merge = loc: defs:
+ let
+ coerce = def: if isFunction def then def else { config = def; };
+ in (import (nixos + "/lib/eval-config.nix") (args // {
+ modules = (args.modules or []) ++
+ map (def: { _file = def.file; imports = [(coerce def.value)]; }) defs;
+
+ prefix = loc;
+ })).config;
+ getSubOptions = prefix: (import (nixos + "/lib/eval-config.nix") (args // {
+ modules = (args.modules or []);
+
+ inherit prefix;
+ })).options;
+ };
+
# Obsolete alternative to configOf. It takes its option
# declarations from the ‘options’ attribute of containing option
# declaration.