niksos/modules/other/hardware.nix

67 lines
2.4 KiB
Nix

{
config,
lib,
...
}: let
cfg = config.myOptions.other.hardware;
inherit (lib) mkIf mkOption;
inherit (lib.types) attrsOf float int submodule;
inherit (lib.types.ints) positive;
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";
type = positive;
};
h = mkOption {
description = "monitor height";
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;
};
y = mkOption {
description = "monitor y position";
type = int;
};
};
};
};
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;
};
}