···1616 # we have to rexport the functions we want to use, but don't want to refer to the whole lib
1717 # "path". e.g. gardenLib.hardware.isx86Linux can be shortened to gardenLib.isx86Linux
1818 # NOTE: never rexport templates
1919- inherit (final.hardware) isx86Linux primaryMonitor ldTernary;
1919+ inherit (final.hardware) isx86Linux ldTernary;
2020 inherit (final.helpers)
2121 mkPubs
2222 giturl
+1-24
modules/flake/lib/hardware.nix
···5151 d
5252 else
5353 throw "Unsupported system: ${pkgs.stdenv.system}";
5454-5555- /**
5656- assume the first monitor in the list of monitors is primary
5757- get its name from the list of monitors
5858-5959- # Arguments
6060-6161- - [config] the configuration that nixosConfigurations provides
6262-6363- # Type
6464-6565- ```
6666- primaryMonitor :: AttrSet -> String
6767- ```
6868-6969- # Example
7070-7171- ```nix
7272- primaryMonitor osConfig
7373- => "DP-1"
7474- ```
7575- */
7676- primaryMonitor = config: builtins.elemAt config.garden.device.monitors 0;
7754in
7855{
7979- inherit isx86Linux primaryMonitor ldTernary;
5656+ inherit isx86Linux ldTernary;
8057}
+46-5
modules/nixos/hardware/options.nix
···11{ lib, ... }:
22let
33- inherit (lib.options) mkOption;
44- inherit (lib.types) listOf str enum;
33+ inherit (lib) mkOption types;
54in
65{
76 options.garden.device = {
87 monitors = mkOption {
99- type = listOf str;
1010- default = [ ];
88+ type = types.attrsOf (
99+ types.submodule (
1010+ { name, ... }:
1111+ {
1212+ options = {
1313+ name = mkOption {
1414+ type = types.str;
1515+ default = name;
1616+ description = "the name of the monitor";
1717+ example = "HDMI-1";
1818+ };
1919+2020+ width = mkOption {
2121+ type = types.int;
2222+ default = 1920;
2323+ example = 1080;
2424+ description = "the width of the monitor in pixels";
2525+ };
2626+2727+ height = mkOption {
2828+ type = types.int;
2929+ default = 1080;
3030+ example = 1024;
3131+ description = "the height of the monitor in pixels";
3232+ };
3333+3434+ refresh-rate = mkOption {
3535+ type = types.int;
3636+ default = 60;
3737+ example = 120;
3838+ description = "the refresh rate of the monitor in Hz";
3939+ };
4040+4141+ scale = mkOption {
4242+ type = types.float;
4343+ default = 1.0;
4444+ example = 1.5;
4545+ description = "the scale factor for the monitor";
4646+ };
4747+ };
4848+ }
4949+ )
5050+ );
5151+1152 description = ''
1253 this does not affect any drivers and such, it is only necessary for
1354 declaring things like monitors in window manager configurations
···1657 };
17581859 keyboard = mkOption {
1919- type = enum [
6060+ type = types.enum [
2061 "us"
2162 "gb"
2263 ];