niksos/modules/other/hardware.nix

74 lines
2.6 KiB
Nix
Raw Normal View History

2024-05-09 18:15:08 +02:00
{
config,
lib,
...
}: let
2024-07-15 23:18:25 +02:00
cfg = config.poz.other.hardware;
2024-05-09 18:15:08 +02:00
2024-07-24 18:47:53 +02:00
inherit (lib.attrsets) mapAttrsToList;
2024-07-25 11:45:44 +02:00
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption;
inherit (lib.types) attrsOf float int submodule;
2024-05-09 18:21:10 +02:00
inherit (lib.types.ints) positive;
2024-05-09 18:15:08 +02:00
in {
2024-07-15 23:18:25 +02:00
options.poz.other.hardware = {
2024-05-09 18:15:08 +02:00
monitors = mkOption {
description = "hostname for this system";
type = attrsOf (submodule {
options = {
resolution = mkOption {
description = "monitor resolution";
type = submodule {
options = {
w = mkOption {
description = "monitor width";
2024-05-09 18:15:08 +02:00
type = positive;
};
h = mkOption {
description = "monitor height";
2024-05-09 18:15:08 +02:00
type = positive;
};
};
};
};
refreshRate = mkOption {
description = "monitor refresh rate";
type = positive;
};
position = mkOption {
description = "monitor position";
type = submodule {
options = {
x = mkOption {
description = "monitor x position";
type = int;
2024-05-09 18:15:08 +02:00
};
y = mkOption {
description = "monitor y position";
type = int;
2024-05-09 18:15:08 +02:00
};
};
};
};
scale = mkOption {
description = "monitor scale";
type = float;
};
};
});
2024-05-13 22:58:31 +02:00
default = {};
2024-05-09 18:15:08 +02:00
};
};
2024-05-13 22:58:31 +02:00
config = mkIf (cfg.monitors != {}) {
2024-07-22 21:54:01 +02:00
boot.kernelParams = mapAttrsToList (name: m: let
xres = toString m.resolution.w;
yres = toString m.resolution.h;
refresh = toString m.refreshRate;
in
# https://www.kernel.org/doc/html/latest/fb/modedb.html
"video=${name}:${xres}x${yres}@${refresh}"
2024-05-09 18:15:08 +02:00
) cfg.monitors;
};
}