HASH ce67d0de9b43
DATE 2025-01-13
SUBJECT hardware: remove monitor.workspace option, add primaryMonitor option
FILES 4 CHANGED
HASH ce67d0de9b43
DATE 2025-01-13
SUBJECT hardware: remove monitor.workspace
option, add primaryMonitor option
FILES 4 CHANGED
┌─ hosts/ooksdesk/hardware.nix ──────────────────────────────────────────────┐
│ diff --git a/hosts/ooksdesk/hardware.nix b/hosts/ooksdesk/hardware.nix │
│ index 703abeb..94e6c27 100644 │
│ --- a/hosts/ooksdesk/hardware.nix │
│ +++ b/hosts/ooksdesk/hardware.nix │
│ @@ -14,7 +14,6 @@ │
│ width = 2560; │
│ height = 1440; │
│ refreshRate = 144; │
│ - workspace = "1"; │
│ x = 1920; │
│ y = 100; │
│ } │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ hosts/ooksdesk/hardware.nix ────────┐
│ diff --git a/hosts/ooksdesk/hardware.nix b/h │
│ osts/ooksdesk/hardware.nix │
│ index 703abeb..94e6c27 100644 │
│ --- a/hosts/ooksdesk/hardware.nix │
│ +++ b/hosts/ooksdesk/hardware.nix │
│ @@ -14,7 +14,6 @@ │
│ width = 2560; │
│ height = 1440; │
│ refreshRate = 144; │
│ - workspace = "1"; │
│ x = 1920; │
│ y = 100; │
│ } │
└──────────────────────────────────────────────┘
┌─ hosts/ooksmedia/hardware.nix ─────────────────────────────────────────────┐
│ diff --git a/hosts/ooksmedia/hardware.nix b/hosts/ooksmedia/hardware.nix │
│ index bc4629e..6ed6778 100644 │
│ --- a/hosts/ooksmedia/hardware.nix │
│ +++ b/hosts/ooksmedia/hardware.nix │
│ @@ -10,7 +10,6 @@ │
│ width = 1920; │
│ height = 1080; │
│ refreshRate = 180; │
│ - workspace = "1"; │
│ } │
│ ]; │
│ }; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ hosts/ooksmedia/hardware.nix ───────┐
│ diff --git a/hosts/ooksmedia/hardware.nix b/ │
│ hosts/ooksmedia/hardware.nix │
│ index bc4629e..6ed6778 100644 │
│ --- a/hosts/ooksmedia/hardware.nix │
│ +++ b/hosts/ooksmedia/hardware.nix │
│ @@ -10,7 +10,6 @@ │
│ width = 1920; │
│ height = 1080; │
│ refreshRate = 180; │
│ - workspace = "1"; │
│ } │
│ ]; │
│ }; │
└──────────────────────────────────────────────┘
┌─ hosts/ookst480s/hardware.nix ─────────────────────────────────────────────┐
│ diff --git a/hosts/ookst480s/hardware.nix b/hosts/ookst480s/hardware.nix │
│ index d67061d..73dff74 100644 │
│ --- a/hosts/ookst480s/hardware.nix │
│ +++ b/hosts/ookst480s/hardware.nix │
│ @@ -16,7 +16,6 @@ │
│ name = "eDP-1"; │
│ width = 1920; │
│ height = 1080; │
│ - workspace = "1"; │
│ } │
│ ]; │
│ }; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ hosts/ookst480s/hardware.nix ───────┐
│ diff --git a/hosts/ookst480s/hardware.nix b/ │
│ hosts/ookst480s/hardware.nix │
│ index d67061d..73dff74 100644 │
│ --- a/hosts/ookst480s/hardware.nix │
│ +++ b/hosts/ookst480s/hardware.nix │
│ @@ -16,7 +16,6 @@ │
│ name = "eDP-1"; │
│ width = 1920; │
│ height = 1080; │
│ - workspace = "1"; │
│ } │
│ ]; │
│ }; │
└──────────────────────────────────────────────┘
┌─ modules/nixos/hardware/options.nix ───────────────────────────────────────┐
│ diff --git a/modules/nixos/hardware/options.nix b/modules/nixos/hardware/options.n │
│ ix │
│ index 44a4a36..864eba3 100644 │
│ --- a/modules/nixos/hardware/options.nix │
│ +++ b/modules/nixos/hardware/options.nix │
│ @@ -3,9 +3,14 @@ │
│ config, │
│ ... │
│ }: let │
│ + inherit (builtins) filter length head; │
│ inherit (lib) mkOption mkEnableOption; │
│ 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 { │
│ options.ooknet.hardware = { │
│ gpu = { │
│ @@ -21,10 +26,14 @@ in { │
│ default = null; │
│ }; │
│ amd.pstate.enable = mkEnableOption ""; │
│ - cores = { │
│ + cores = mkOption { │
│ type = int; │
│ description = "Number of Physical CPU cores the system has"; │
│ }; │
│ + threads = mkOption { │
│ + type = int; │
│ + description = "Number of cpu threads the cpu has"; │
│ + }; │
│ }; │
│ │
│ features = mkOption { │
│ @@ -43,6 +52,15 @@ in { │
│ │
│ # monitor module inspired by misterio77 │
│ # 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 { │
│ type = listOf (submodule { │
│ options = { │
│ @@ -82,10 +100,6 @@ in { │
│ type = bool; │
│ default = true; │
│ }; │
│ - workspace = mkOption { │
│ - type = nullOr str; │
│ - default = null; │
│ - }; │
│ }; │
│ }); │
│ default = []; │
│ @@ -95,10 +109,8 @@ in { │
│ config = { │
│ assertions = [ │
│ { │
│ - assertion = │
│ - ((lib.length hardware.monitors) != 0) │
│ - -> ((lib.length (lib.filter (m: m.primary) hardware.monitors)) == 1); │
│ - message = "At least 1 primary monitor is required"; │
│ + assertion = hasMonitors -> primaryCount == 1; │
│ + message = "Error: config.ooknet.hardware.monitors. When monitors are conf │
│ igured, exactly one monitor must be designated as primary (found ${toString primar │
│ yCount} primary monitors)"; │
│ } │
│ ]; │
│ }; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...es/nixos/hardware/options.nix ───┐
│ diff --git a/modules/nixos/hardware/options. │
│ nix b/modules/nixos/hardware/options.nix │
│ index 44a4a36..864eba3 100644 │
│ --- a/modules/nixos/hardware/options.nix │
│ +++ b/modules/nixos/hardware/options.nix │
│ @@ -3,9 +3,14 @@ │
│ config, │
│ ... │
│ }: let │
│ + inherit (builtins) filter length head; │
│ inherit (lib) mkOption mkEnableOption; │
│ inherit (lib.types) nullOr enum bool subm │
│ odule listOf int str; │
│ - inherit (config.ooknet) hardware; │
│ + │
│ + cfg = config.ooknet.hardware; │
│ + hasMonitors = length cfg.monitors != 0; │
│ + primaryAttr = filter (m: m.primary or fal │
│ se) cfg.monitors; │
│ + primaryCount = length primaryAttr; │
│ in { │
│ options.ooknet.hardware = { │
│ gpu = { │
│ @@ -21,10 +26,14 @@ in { │
│ default = null; │
│ }; │
│ amd.pstate.enable = mkEnableOption "" │
│ ; │
│ - cores = { │
│ + cores = mkOption { │
│ type = int; │
│ description = "Number of Physical C │
│ PU cores the system has"; │
│ }; │
│ + threads = mkOption { │
│ + type = int; │
│ + description = "Number of cpu thread │
│ s the cpu has"; │
│ + }; │
│ }; │
│ │
│ features = mkOption { │
│ @@ -43,6 +52,15 @@ in { │
│ │
│ # monitor module inspired by misterio77 │
│ # includes the addition of transform op │
│ tion │
│ + primaryMonitor = mkOption { │
│ + type = nullOr str; │
│ + default = │
│ + if !hasMonitors │
│ + then null │
│ + else (head primaryAttr).name; │
│ + description = "Name of the primary mo │
│ nitor, derived from the monitors list"; │
│ + readOnly = true; │
│ + }; │
│ monitors = mkOption { │
│ type = listOf (submodule { │
│ options = { │
│ @@ -82,10 +100,6 @@ in { │
│ type = bool; │
│ default = true; │
│ }; │
│ - workspace = mkOption { │
│ - type = nullOr str; │
│ - default = null; │
│ - }; │
│ }; │
│ }); │
│ default = []; │
│ @@ -95,10 +109,8 @@ in { │
│ config = { │
│ assertions = [ │
│ { │
│ - assertion = │
│ - ((lib.length hardware.monitors) ! │
│ = 0) │
│ - -> ((lib.length (lib.filter (m: m │
│ .primary) hardware.monitors)) == 1); │
│ - message = "At least 1 primary monit │
│ or is required"; │
│ + assertion = hasMonitors -> primaryC │
│ ount == 1; │
│ + message = "Error: config.ooknet.har │
│ dware.monitors. When monitors are configured │
│ , exactly one monitor must be designated as │
│ primary (found ${toString primaryCount} prim │
│ ary monitors)"; │
│ } │
│ ]; │
│ }; │
└──────────────────────────────────────────────┘
[ BACK TO LOG ]
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET