73 lines
2.2 KiB
Nix
73 lines
2.2 KiB
Nix
|
{ pkgs, config, ... }:
|
||
|
let
|
||
|
inherit (pkgs) lib;
|
||
|
inherit (lib) types mkEnableOption mkOption mkIf;
|
||
|
cfg = config.machineVars;
|
||
|
in {
|
||
|
options.machineVars = {
|
||
|
headless = mkEnableOption "Whether or not the machine should have graphical output.";
|
||
|
|
||
|
screens = mkOption {
|
||
|
type = types.attrsOf (types.submodule ( { name, ...}: {
|
||
|
options = {
|
||
|
resolution = mkOption {
|
||
|
type = types.str;
|
||
|
example = "1920x1080";
|
||
|
description = "The resolution of the screen";
|
||
|
};
|
||
|
|
||
|
name = mkOption {
|
||
|
type = types.str;
|
||
|
default = name;
|
||
|
example = "DP-1";
|
||
|
description = "The name of the screen";
|
||
|
};
|
||
|
|
||
|
freq = mkOption {
|
||
|
type = types.nullOr types.str;
|
||
|
example = "60.00";
|
||
|
description = "The update frequency of the screen, defined in Hz";
|
||
|
};
|
||
|
};
|
||
|
}));
|
||
|
default = { };
|
||
|
description = "A detailed description of the machines screens.";
|
||
|
};
|
||
|
|
||
|
gaming = mkEnableOption "Whether or not the machine should have gaming software installed.";
|
||
|
development = mkEnableOption "Whether or not the machine should come with developmen
|
||
|
t tools preinstalled.";
|
||
|
creative = mkEnableOption "Whether or not the machine should have creative software
|
||
|
(music, video and image editing) installed.";
|
||
|
|
||
|
laptop = mkEnableOption "Whether the machine is a laptop";
|
||
|
|
||
|
fixDisplayCommand = mkOption {
|
||
|
type = types.nullOr types.str;
|
||
|
default = null;
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = {
|
||
|
assertions = [
|
||
|
{
|
||
|
assertion = cfg.headless -> !cfg.creative;
|
||
|
message = "A headless machine can't have creative software installed.";
|
||
|
}
|
||
|
{
|
||
|
assertion = cfg.headless -> !cfg.gaming;
|
||
|
message = "A headless machine can't have gaming software installed.";
|
||
|
}
|
||
|
{
|
||
|
assertion = cfg.headless -> (cfg.screens == { } && cfg.fixDisplayCommand == null);
|
||
|
message = "A headless machine can't have any screens.";
|
||
|
}
|
||
|
];
|
||
|
|
||
|
warnings = lib.optionals (0 < (lib.length (builtins.attrNames cfg.screens)) && (cfg.fixDisplayCommand != null)) [
|
||
|
"You are overriding the fixDisplayCommand even though machineVars.screens is defined. One of these should be omitted"
|
||
|
];
|
||
|
};
|
||
|
}
|
||
|
|