core/lib/tests/modules/class-check.nix

78 lines
1.5 KiB
Nix
Raw Normal View History

2024-06-30 08:16:52 +00:00
{ lib, ... }:
{
2024-05-01 22:14:04 +00:00
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;
2024-06-30 08:16:52 +00:00
ok = lib.evalModules {
class = "nixos";
modules = [ ./module-class-is-nixos.nix ];
};
2024-05-01 22:14:04 +00:00
2024-06-30 08:16:52 +00:00
fail = lib.evalModules {
class = "nixos";
modules = [
./module-class-is-nixos.nix
./module-class-is-darwin.nix
];
};
2024-05-01 22:14:04 +00:00
2024-06-30 08:16:52 +00:00
fail-anon = lib.evalModules {
class = "nixos";
modules = [
./module-class-is-nixos.nix
{
_file = "foo.nix#darwinModules.default";
_class = "darwin";
config = { };
imports = [ ];
}
];
};
2024-05-01 22:14:04 +00:00
2024-06-30 08:16:52 +00:00
sub.nixosOk = {
_class = "nixos";
};
sub.nixosFail = {
imports = [ ./module-class-is-darwin.nix ];
};
2024-05-01 22:14:04 +00:00
};
}