diff --git a/config/Display.nix b/config/Display.nix new file mode 100644 index 00000000..13b172b4 --- /dev/null +++ b/config/Display.nix @@ -0,0 +1,42 @@ +{ + lib, + config, + ... +}: let + cfg = config.module.display; +in { + # REF: https://www.kernel.org/doc/Documentation/fb/fbcon.txt + # REF: https://patchwork.kernel.org/project/dri-devel/patch/20191110154101.26486-10-hdegoede@redhat.com/#22993841 + config = lib.mkMerge [ + # NOTE: `tty` name is special. + (lib.mkIf (cfg.rotate != null) { + boot.kernelParams = lib.mapAttrsToList (name: rotate: + let + hint = + if rotate == 90 then "left_side_up" + else if rotate == 180 then "upside_down" + else if rotate == 270 then "right_side_up" + else "normal"; + + value = + if rotate == 90 then 1 + else if rotate == 180 then 2 + else if rotate == 270 then 3 + else 0; + + command = if name == "tty" then + "fbcon=rotate:${toString value}" + else + "video=${name}:rotate=${toString rotate}"; + # "video=${name}:panel_orientation=${hint}"; + # "video=${name}:rotate=${toString rotate},panel_orientation=${hint}"; + in command + ) cfg.rotate; + + module.sway.extraConfig = lib.mapAttrsToList (name: rotate: + "output ${name} transform ${toString rotate}" + ) cfg.rotate; + }) + ]; +} + diff --git a/config/Purpose.nix b/config/Purpose.nix index 8f84c107..0ddb9db7 100644 --- a/config/Purpose.nix +++ b/config/Purpose.nix @@ -101,7 +101,6 @@ in { (lib.mkIf cfg.server { module = { - keyd.enable = true; kernel = { enable = true; hardening = true; diff --git a/home/file/sway/default.nix b/home/file/sway/default.nix index 9e3d37fa..fa07c8b5 100644 --- a/home/file/sway/default.nix +++ b/home/file/sway/default.nix @@ -1,6 +1,7 @@ { - util, config, + lib, + util, ... } @args: let swayRc = util.catText [ @@ -32,6 +33,6 @@ in { include /etc/sway/config.d/* '') + swayRc - + config.module.sway.extraConfig + + lib.concatStringsSep "\n" config.module.sway.extraConfig ; } diff --git a/home/file/waybar/config/default.nix b/home/file/waybar/config/default.nix index 251c2eb5..3c73d018 100644 --- a/home/file/waybar/config/default.nix +++ b/home/file/waybar/config/default.nix @@ -16,10 +16,7 @@ in { spacing = 4; start_hidden = false; output = [ - "!AOC 24G2W1G4 ATNL61A129625" # Dasha monitor. - "!Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" # Desktop monitor. - "!UGD Artist15.6Pro 20200316" # XP-Pen Tablet. - "*" + config.module.display.primary ]; modules-left = [ "clock" diff --git a/host/x86_64-linux/dasha/default.nix b/host/x86_64-linux/dasha/default.nix index 8100c60b..2a8f49ca 100644 --- a/host/x86_64-linux/dasha/default.nix +++ b/host/x86_64-linux/dasha/default.nix @@ -6,10 +6,11 @@ }; module = { + amd.gpu.enable = true; builder.client.enable = true; - amd.gpu.enable = true; - package.extra = true; - print.enable = true; + display.primary = "DP-1"; + package.extra = true; + print.enable = true; purpose = { creativity = true; desktop = true; diff --git a/host/x86_64-linux/desktop/default.nix b/host/x86_64-linux/desktop/default.nix index e8351da8..c69f5f01 100644 --- a/host/x86_64-linux/desktop/default.nix +++ b/host/x86_64-linux/desktop/default.nix @@ -14,6 +14,10 @@ gaming = true; work = true; }; + display = { + primary = "HDMI-A-1"; + rotate.HDMI-A-1 = 180; + }; amd = { compute.enable = true; gpu.enable = true; @@ -22,11 +26,11 @@ powersave = true; }; }; - sway.extraConfig = '' - output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165" mode 1920x1080@74.986Hz transform 180 pos 780,0 - output "Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" pos 0,1080 - workspace 1 output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165" - ''; + sway.extraConfig = [ + "output DP-3 pos 0,1080" + "output HDMI-A-1 mode 1920x1080@74.986Hz pos 780,0" + "workspace 1 output HDMI-A-1" + ]; hwmon = { file = "temp1_input"; path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; diff --git a/host/x86_64-linux/home/default.nix b/host/x86_64-linux/home/default.nix index 48d6d9fa..879877c2 100644 --- a/host/x86_64-linux/home/default.nix +++ b/host/x86_64-linux/home/default.nix @@ -7,6 +7,7 @@ module = { builder.server.enable = true; + display.primary = "HDMI-A-1"; purpose = { desktop = true; router = true; diff --git a/host/x86_64-linux/laptop/default.nix b/host/x86_64-linux/laptop/default.nix index 0ae82919..1e1a8f85 100644 --- a/host/x86_64-linux/laptop/default.nix +++ b/host/x86_64-linux/laptop/default.nix @@ -8,6 +8,7 @@ module = { builder.client.enable = true; + display.primary = "eDP-1"; print.enable = true; purpose = { creativity = true; diff --git a/host/x86_64-linux/pocket/Boot.nix b/host/x86_64-linux/pocket/Boot.nix deleted file mode 100644 index 71b1c469..00000000 --- a/host/x86_64-linux/pocket/Boot.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ ... }: { - boot.kernelParams = [ - "fbcon=rotate:1" - "video=DSI-1:rotate=90" - ]; -} diff --git a/host/x86_64-linux/pocket/default.nix b/host/x86_64-linux/pocket/default.nix index be6f14ae..321255f7 100644 --- a/host/x86_64-linux/pocket/default.nix +++ b/host/x86_64-linux/pocket/default.nix @@ -15,10 +15,16 @@ laptop = true; work = true; }; - sway.extraConfig = '' - output DSI-1 transform 90 - input type:touch map_to_output DSI-1 - ''; + display = { + primary = "DSI-1"; + rotate = { + tty = 90; + DSI-1 = 90; + }; + }; + sway.extraConfig = [ + "input type:touch map_to_output DSI-1" + ]; hwmon = { file = "temp1_input"; path = "/sys/devices/platform/coretemp.0/hwmon"; diff --git a/host/x86_64-linux/work/default.nix b/host/x86_64-linux/work/default.nix index 1871faa2..7a43b0d4 100644 --- a/host/x86_64-linux/work/default.nix +++ b/host/x86_64-linux/work/default.nix @@ -11,6 +11,7 @@ module = { builder.client.enable = true; + display.primary = "DSI-1"; package.extra = true; powerlimit.thinkpad.enable = true; print.enable = true; diff --git a/option/Display.nix b/option/Display.nix index 25e31a5e..20e719bf 100644 --- a/option/Display.nix +++ b/option/Display.nix @@ -3,8 +3,18 @@ lib, ... }: { - options.module.display.dpiAware = lib.mkOption { - default = false; - type = lib.types.bool; + options.module.display = { + dpiAware = lib.mkOption { + default = false; + type = lib.types.bool; + }; + primary = lib.mkOption { + default = "*"; + type = lib.types.str; + }; + rotate = lib.mkOption { + default = { }; + type = with lib.types; attrsOf (enum [ 0 90 180 270 ]); + }; }; } diff --git a/option/Sway.nix b/option/Sway.nix index df714b8d..9eb3f5a1 100644 --- a/option/Sway.nix +++ b/option/Sway.nix @@ -5,8 +5,8 @@ options.module.sway = { enable = lib.mkEnableOption "the Sway WM."; extraConfig = lib.mkOption { - default = ""; - type = lib.types.str; + default = [ ]; + type = with lib.types; listOf str; }; }; }