niksos/modules/other/hardware.nix

63 lines
2.1 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 positive submodule;
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 {
type = positive;
};
h = mkOption {
type = positive;
};
};
};
};
refreshRate = mkOption {
description = "monitor refresh rate";
type = positive;
};
position = mkOption {
description = "monitor position";
type = submodule {
options = {
x = mkOption {
type = positive;
};
y = mkOption {
type = positive;
};
};
};
};
scale = mkOption {
description = "monitor scale";
type = float;
};
};
});
default = [];
};
};
config = mkIf (cfg.monitors != []) {
boot.kernelParams = mapAttrsToList (name: m:
"video=${name}:${toString m.resolution.w}x${toString m.resolution.h}@${toString m.refreshRate}"
) cfg.monitors;
};
}