diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-01-01 01:11:45 +0100 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2020-01-02 09:59:35 +0100 |
commit | cc81320a46d8f822da90c84aeb413de3e9b5f4a8 (patch) | |
tree | 47cfcef66308ad7f7f134c66838cd68ba180f99a /lib/tests/modules | |
parent | eec83d41e3e7d9ad5bc1086198d972d55bab1203 (diff) |
lib/tests: Add submoduleWith tests
Diffstat (limited to 'lib/tests/modules')
7 files changed, 92 insertions, 0 deletions
diff --git a/lib/tests/modules/declare-submoduleWith-modules.nix b/lib/tests/modules/declare-submoduleWith-modules.nix new file mode 100644 index 000000000000..4736ab41751b --- /dev/null +++ b/lib/tests/modules/declare-submoduleWith-modules.nix @@ -0,0 +1,30 @@ +{ lib, ... }: { + options.submodule = lib.mkOption { + type = lib.types.submoduleWith { + modules = [ + { + options.inner = lib.mkOption { + type = lib.types.bool; + default = false; + }; + } + { + outer = true; + } + ]; + }; + default = {}; + }; + + config.submodule = lib.mkMerge [ + ({ lib, ... }: { + options.outer = lib.mkOption { + type = lib.types.bool; + default = false; + }; + }) + { + inner = true; + } + ]; +} diff --git a/lib/tests/modules/declare-submoduleWith-noshorthand.nix b/lib/tests/modules/declare-submoduleWith-noshorthand.nix new file mode 100644 index 000000000000..af3b4ba470ff --- /dev/null +++ b/lib/tests/modules/declare-submoduleWith-noshorthand.nix @@ -0,0 +1,13 @@ +{ lib, ... }: let + sub.options.config = lib.mkOption { + type = lib.types.bool; + default = false; + }; +in { + options.submodule = lib.mkOption { + type = lib.types.submoduleWith { + modules = [ sub ]; + }; + default = {}; + }; +} diff --git a/lib/tests/modules/declare-submoduleWith-path.nix b/lib/tests/modules/declare-submoduleWith-path.nix new file mode 100644 index 000000000000..477647f32121 --- /dev/null +++ b/lib/tests/modules/declare-submoduleWith-path.nix @@ -0,0 +1,12 @@ +{ lib, ... }: { + options.submodule = lib.mkOption { + type = lib.types.submoduleWith { + modules = [ + ./declare-enable.nix + ]; + }; + default = {}; + }; + + config.submodule = ./define-enable.nix; +} diff --git a/lib/tests/modules/declare-submoduleWith-shorthand.nix b/lib/tests/modules/declare-submoduleWith-shorthand.nix new file mode 100644 index 000000000000..63ac16293e2b --- /dev/null +++ b/lib/tests/modules/declare-submoduleWith-shorthand.nix @@ -0,0 +1,14 @@ +{ lib, ... }: let + sub.options.config = lib.mkOption { + type = lib.types.bool; + default = false; + }; +in { + options.submodule = lib.mkOption { + type = lib.types.submoduleWith { + modules = [ sub ]; + shorthandOnlyDefinesConfig = true; + }; + default = {}; + }; +} diff --git a/lib/tests/modules/declare-submoduleWith-special.nix b/lib/tests/modules/declare-submoduleWith-special.nix new file mode 100644 index 000000000000..6b15c5bde203 --- /dev/null +++ b/lib/tests/modules/declare-submoduleWith-special.nix @@ -0,0 +1,17 @@ +{ lib, ... }: { + options.submodule = lib.mkOption { + type = lib.types.submoduleWith { + modules = [ + ({ lib, ... }: { + options.foo = lib.mkOption { + default = lib.foo; + }; + }) + ]; + specialArgs.lib = lib // { + foo = "foo"; + }; + }; + default = {}; + }; +} diff --git a/lib/tests/modules/define-submoduleWith-noshorthand.nix b/lib/tests/modules/define-submoduleWith-noshorthand.nix new file mode 100644 index 000000000000..35e1607b6f1c --- /dev/null +++ b/lib/tests/modules/define-submoduleWith-noshorthand.nix @@ -0,0 +1,3 @@ +{ + submodule.config.config = true; +} diff --git a/lib/tests/modules/define-submoduleWith-shorthand.nix b/lib/tests/modules/define-submoduleWith-shorthand.nix new file mode 100644 index 000000000000..17df248db8ef --- /dev/null +++ b/lib/tests/modules/define-submoduleWith-shorthand.nix @@ -0,0 +1,3 @@ +{ + submodule.config = true; +} |