diff options
Diffstat (limited to 'tests/modules/class-check.nix')
-rw-r--r-- | tests/modules/class-check.nix | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/modules/class-check.nix b/tests/modules/class-check.nix new file mode 100644 index 000000000..293fd4abd --- /dev/null +++ b/tests/modules/class-check.nix @@ -0,0 +1,76 @@ +{ lib, ... }: { + options = { + sub = { + nixosOk = lib.mkOption { + type = lib.types.submoduleWith { + class = "nixos"; + modules = [ ]; + }; + }; + # Same but will have bad definition + nixosFail = lib.mkOption { + type = lib.types.submoduleWith { + class = "nixos"; + modules = [ ]; + }; + }; + + mergeFail = lib.mkOption { + type = lib.types.submoduleWith { + class = "nixos"; + modules = [ ]; + }; + default = { }; + }; + }; + }; + imports = [ + { + options = { + sub = { + mergeFail = lib.mkOption { + type = lib.types.submoduleWith { + class = "darwin"; + modules = [ ]; + }; + }; + }; + }; + } + ]; + config = { + _module.freeformType = lib.types.anything; + ok = + lib.evalModules { + class = "nixos"; + modules = [ + ./module-class-is-nixos.nix + ]; + }; + + fail = + lib.evalModules { + class = "nixos"; + modules = [ + ./module-class-is-nixos.nix + ./module-class-is-darwin.nix + ]; + }; + + fail-anon = + lib.evalModules { + class = "nixos"; + modules = [ + ./module-class-is-nixos.nix + { _file = "foo.nix#darwinModules.default"; + _class = "darwin"; + config = {}; + imports = []; + } + ]; + }; + + sub.nixosOk = { _class = "nixos"; }; + sub.nixosFail = { imports = [ ./module-class-is-darwin.nix ]; }; + }; +} |