diff options
author | Shea Levy <shea@shealevy.com> | 2014-02-11 14:21:34 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2014-02-11 14:21:34 -0500 |
commit | ca1c5cfa8fff055c74786dbe0d2ca889ae462365 (patch) | |
tree | fd4ce920309cfe522f380edbdae715648388cb30 /lib/types.nix | |
parent | 2deb26bd4a0c21d7c5eef54cdd2f4913699efb7c (diff) | |
download | nixpkgs-ca1c5cfa8fff055c74786dbe0d2ca889ae462365.tar nixpkgs-ca1c5cfa8fff055c74786dbe0d2ca889ae462365.tar.gz nixpkgs-ca1c5cfa8fff055c74786dbe0d2ca889ae462365.tar.bz2 nixpkgs-ca1c5cfa8fff055c74786dbe0d2ca889ae462365.tar.lz nixpkgs-ca1c5cfa8fff055c74786dbe0d2ca889ae462365.tar.xz nixpkgs-ca1c5cfa8fff055c74786dbe0d2ca889ae462365.tar.zst nixpkgs-ca1c5cfa8fff055c74786dbe0d2ca889ae462365.zip |
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.nix | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix index afc8f80eb0e..ac84ef29611 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. |