define yukari's monitors

This commit is contained in:
insects 2024-08-10 21:05:32 +02:00
parent daf734ba0c
commit 27e703cf11
4 changed files with 96 additions and 7 deletions

View file

@ -1,6 +1,3 @@
# Add your reusable home-manager modules to this directory, on their own file (https://nixos.wiki/wiki/Module).
# These should be stuff you would like to share with others, not your personal configurations.
{
# List your module files here
# my-module = import ./my-module.nix;
monitors = import ./monitors.nix;
}

View file

@ -0,0 +1,59 @@
{
lib,
config,
...
}: let
inherit (lib) mkOption types;
in {
options.monitors = mkOption {
type = types.listOf (
types.submodule {
options = {
name = mkOption {
type = types.str;
example = "DP-1";
};
primary = mkOption {
type = types.bool;
default = false;
};
width = mkOption {
type = types.int;
example = 1920;
};
height = mkOption {
type = types.int;
example = 1080;
};
refreshRate = mkOption {
type = types.int;
default = 60;
};
position = mkOption {
type = types.str;
default = "auto";
};
enabled = mkOption {
type = types.bool;
default = true;
};
workspace = mkOption {
type = types.nullOr types.str;
default = null;
};
};
}
);
default = [];
};
config = {
assertions = [
{
assertion =
((lib.length config.monitors) != 0)
-> ((lib.length (lib.filter (m: m.primary) config.monitors)) == 1);
message = "Exactly one monitor must be set to primary.";
}
];
};
}