hardware: remove monitor.workspace option, add primaryMonitor option

This commit is contained in:
ooks-io 2025-01-13 20:56:22 +11:00
parent 338e3a25a1
commit ce67d0de9b
4 changed files with 22 additions and 13 deletions

View file

@ -14,7 +14,6 @@
width = 2560; width = 2560;
height = 1440; height = 1440;
refreshRate = 144; refreshRate = 144;
workspace = "1";
x = 1920; x = 1920;
y = 100; y = 100;
} }

View file

@ -10,7 +10,6 @@
width = 1920; width = 1920;
height = 1080; height = 1080;
refreshRate = 180; refreshRate = 180;
workspace = "1";
} }
]; ];
}; };

View file

@ -16,7 +16,6 @@
name = "eDP-1"; name = "eDP-1";
width = 1920; width = 1920;
height = 1080; height = 1080;
workspace = "1";
} }
]; ];
}; };

View file

@ -3,9 +3,14 @@
config, config,
... ...
}: let }: let
inherit (builtins) filter length head;
inherit (lib) mkOption mkEnableOption; inherit (lib) mkOption mkEnableOption;
inherit (lib.types) nullOr enum bool submodule listOf int str; inherit (lib.types) nullOr enum bool submodule listOf int str;
inherit (config.ooknet) hardware;
cfg = config.ooknet.hardware;
hasMonitors = length cfg.monitors != 0;
primaryAttr = filter (m: m.primary or false) cfg.monitors;
primaryCount = length primaryAttr;
in { in {
options.ooknet.hardware = { options.ooknet.hardware = {
gpu = { gpu = {
@ -21,10 +26,14 @@ in {
default = null; default = null;
}; };
amd.pstate.enable = mkEnableOption ""; amd.pstate.enable = mkEnableOption "";
cores = { cores = mkOption {
type = int; type = int;
description = "Number of Physical CPU cores the system has"; description = "Number of Physical CPU cores the system has";
}; };
threads = mkOption {
type = int;
description = "Number of cpu threads the cpu has";
};
}; };
features = mkOption { features = mkOption {
@ -43,6 +52,15 @@ in {
# monitor module inspired by misterio77 # monitor module inspired by misterio77
# includes the addition of transform option # includes the addition of transform option
primaryMonitor = mkOption {
type = nullOr str;
default =
if !hasMonitors
then null
else (head primaryAttr).name;
description = "Name of the primary monitor, derived from the monitors list";
readOnly = true;
};
monitors = mkOption { monitors = mkOption {
type = listOf (submodule { type = listOf (submodule {
options = { options = {
@ -82,10 +100,6 @@ in {
type = bool; type = bool;
default = true; default = true;
}; };
workspace = mkOption {
type = nullOr str;
default = null;
};
}; };
}); });
default = []; default = [];
@ -95,10 +109,8 @@ in {
config = { config = {
assertions = [ assertions = [
{ {
assertion = assertion = hasMonitors -> primaryCount == 1;
((lib.length hardware.monitors) != 0) message = "Error: config.ooknet.hardware.monitors. When monitors are configured, exactly one monitor must be designated as primary (found ${toString primaryCount} primary monitors)";
-> ((lib.length (lib.filter (m: m.primary) hardware.monitors)) == 1);
message = "At least 1 primary monitor is required";
} }
]; ];
}; };