59 lines
1.7 KiB
Nix
59 lines
1.7 KiB
Nix
{ config, lib, ...}: with lib;
|
|
let
|
|
cfg = config.kyouma.machine-type;
|
|
in {
|
|
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.";
|
|
};
|
|
};
|
|
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";
|
|
}
|
|
];
|
|
deployment.tags = mkIf cfg.router [ "router" ];
|
|
};
|
|
}
|