diff --git a/hosts/common.nix b/hosts/common.nix index d16f24b..5b3aaa5 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -152,17 +152,17 @@ in { }; }; - shellAliases.fixDisplay = let + shellAliases.fixdisplay = let inherit (config.machineVars) screens headless fixDisplayCommand; - screenToArgs = screen: with screen; - "--output ${name} --mode ${resolution}" - + (lib.optionalString (frequency != null) " --rate ${frequency}"); + screenToArgs = name: screen: with screen; + "--output ${name} --mode ${resolution} --rate ${toString frequency} --pos ${position}" + + (lib.optionalString primary " --primary"); screenArgs = lib.concatStringsSep " " (lib.mapAttrsToList screenToArgs screens); in lib.mkIf (!headless) - (if screenArgs == null + (if screenArgs != null then "xrandr ${screenArgs}" else (lib.mkIf (fixDisplayCommand != null) fixDisplayCommand)); }; @@ -305,6 +305,7 @@ in { light.enable = !config.machineVars.headless; npm.enable = true; tmux.enable = true; + zsh.enable = true; gnupg.agent = { enable = true; diff --git a/hosts/eisei/configuration.nix b/hosts/eisei/configuration.nix index 4feb9f6..100a0ad 100644 --- a/hosts/eisei/configuration.nix +++ b/hosts/eisei/configuration.nix @@ -20,11 +20,7 @@ in { headless = false; laptop = true; - screens = { - "eDP-1" = { - resolution = "1920x1080"; - }; - }; + screens."eDP-1".primary = true; }; systemd.targets = { diff --git a/hosts/kasei/configuration.nix b/hosts/kasei/configuration.nix index 60b6729..a50a2ff 100644 --- a/hosts/kasei/configuration.nix +++ b/hosts/kasei/configuration.nix @@ -25,12 +25,15 @@ default = main; }; - fixDisplayCommand = "xrandr --output DP-4 --mode 1920x1080 --pos 0x0 -r 144 --output HDMI-0 --primary --mode 1920x1080 --pos 1920x0 -r 60"; - - # screens = { - # "DP-1" = {}; - # "HDMI-1" = {}; - # }; + screens = { + DP-4 = { + primary = true; + frequency = 144; + }; + HDMI-0 = { + position = "1920x0"; + }; + }; }; systemd.targets = { diff --git a/modules/machineVars.nix b/modules/machineVars.nix index 57764dd..a083bd3 100644 --- a/modules/machineVars.nix +++ b/modules/machineVars.nix @@ -9,12 +9,6 @@ in { screens = mkOption { type = types.attrsOf (types.submodule ( { name, ...}: { options = { - resolution = mkOption { - type = types.str; - example = "1920x1080"; - description = "The resolution of the screen"; - }; - name = mkOption { type = types.str; default = name; @@ -22,11 +16,28 @@ in { description = "The name of the screen"; }; - freq = mkOption { - type = types.nullOr types.str; - example = "60.00"; + primary = mkEnableOption "Whether this screen should be the primary one. There can only be one primary screen"; + + resolution = mkOption { + type = types.str; + example = "3840x2160"; + default = "1920x1080"; + description = "The resolution of the screen"; + }; + + frequency = mkOption { + type = types.ints.positive; + example = 144; + default = 60; description = "The update frequency of the screen, defined in Hz"; }; + + position = mkOption { + type = types.str; + example = "1920x0"; + default = "0x0"; + description = "The position of the screen, compared to the other screens"; + }; }; })); default = { }; @@ -102,6 +113,11 @@ t tools preinstalled."; assertion = cfg.battery != null -> cfg.laptop; message = "A battery shouldn't exist on a non laptop machine"; } + # FIXME: + # { + # assertion = map () (cfg.screens) + # message = "There can only be one primary screen."; + # } ]; warnings = lib.optionals (0 < (lib.length (builtins.attrNames cfg.screens)) && (cfg.fixDisplayCommand != null)) [