niksos/modules/other/hardware.nix

68 lines
2.4 KiB
Nix
Raw Normal View History

2024-05-09 18:15:08 +02:00
{
config,
lib,
...
}: let
cfg = config.myOptions.other.hardware;
inherit (lib) mkIf 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
inherit (lib.attrsets) mapAttrsToList;
in {
options.myOptions.other.hardware = {
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-05-09 18:15:08 +02:00
boot.kernelParams = mapAttrsToList (name: m:
"video=${name}:${toString m.resolution.w}x${toString m.resolution.h}@${toString m.refreshRate}"
) cfg.monitors;
};
}