1
0
Fork 0
forked from emily/nixfiles
nixfiles-emily/modules/machine-type/default.nix

60 lines
1.7 KiB
Nix
Raw Normal View History

2024-02-05 22:22:40 +01:00
{ config, lib, ...}: with lib;
let
cfg = config.kyouma.machine-type;
in {
2024-01-17 14:34:33 +01:00
options.kyouma.machine-type = {
physical = mkOption {
type = types.bool;
default = false;
description = mdDoc "Mark machine as physical.";
};
virtual = mkOption {
type = types.bool;
default = false;
description = mdDoc "Mark machine as virtual.";
};
router = mkOption {
type = types.bool;
default = false;
description = mdDoc "Mark machine as router.";
};
headless = mkOption {
type = types.bool;
default = false;
description = mdDoc "Mark machine as headless.";
};
graphical = mkOption {
type = types.bool;
default = false;
description = mdDoc "Mark machine as graphical.";
};
portable = mkOption {
type = types.bool;
default = false;
description = mdDoc "Mark machine as portable.";
};
};
2024-02-05 22:22:40 +01:00
config = {
assertions = [
{ assertion = !(cfg.physical && cfg.virtual);
message = "machine-type.physical and machine-type.virtual are mutually exclusive";
}
{ assertion = !(cfg.headless && cfg.graphical);
message = "machine-type.headless and machine-type.graphical are mutually exclusive";
}
{ assertion = if cfg.router then cfg.headless == cfg.router else true;
message = "hosts of machine-type.router must also be machine-type.headless";
}
{ assertion = if cfg.portable then cfg.physical == cfg.portable else true;
message = "hosts of machine-type.protable must also be machine-type.physical";
}
];
2024-01-17 14:34:33 +01:00
deployment.tags = mkIf cfg.router [ "router" ];
};
}