From 7b9d9053bff3daec81e2afebbb4f089341abb368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sun, 9 Jun 2024 14:52:31 +0200 Subject: [PATCH] autorandr: deterministic and applies for LigthDM --- curacao/hardware.nix | 58 ++++++++++++++++++++++--- hm/desktop/autorandr/default.nix | 1 - os/default.nix | 2 +- os/desktop/autorandr.nix | 21 +++++++++ os/{desktop.nix => desktop/default.nix} | 3 ++ os/{ => desktop}/qwerty-fr-keypad.diff | 0 6 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 os/desktop/autorandr.nix rename os/{desktop.nix => desktop/default.nix} (97%) rename os/{ => desktop}/qwerty-fr-keypad.diff (100%) diff --git a/curacao/hardware.nix b/curacao/hardware.nix index 21419b0..55fccc1 100644 --- a/curacao/hardware.nix +++ b/curacao/hardware.nix @@ -1,4 +1,20 @@ { pkgs, lib, config, nixos-hardware, displaylinknixpkgs, ... }: +let + displays = { + embedded = { + output = "eDP-1"; + edid = "00ffffffffffff000dae381700000000011c01049526157802a155a556519d280b505400000001010101010101010101010101010101b43b804a71383440302035007dd61000001ac32f804a71383440302035007dd61000001a000000fe003059395747803137334843450a00000000000041319e001000000a010a2020004f"; + }; + deskLeft = { + output = "HDMI-1-3"; # Internal HDMI port + edid = "00ffffffffffff004c2d7b09333032302f160103803420782a01f1a257529f270a505423080081c0810081809500a9c0b300d1c00101283c80a070b023403020360006442100001a000000fd00353f1e5111000a202020202020000000fc00533234423432300a2020202020000000ff0048344d434230333533340a2020010702010400023a80d072382d40102c458006442100001e011d007251d01e206e28550006442100001e011d00bc52d01e20b828554006442100001e8c0ad090204031200c4055000644210000188c0ad08a20e02d10103e9600064421000018000000000000000000000000000000000000000000000000000000000000000000d2"; + }; + deskRight = { + output = "DVI-I-2-1"; # DisplayLink + edid = "00ffffffffffff004c2d7b093330323020160103803420782a01f1a257529f270a505423080081c0810081809500a9c0b300d1c00101283c80a070b023403020360006442100001a000000fd00353f1e5111000a202020202020000000fc00533234423432300a2020202020000000ff0048344d433830303836350a2020011c02010400023a80d072382d40102c458006442100001e011d007251d01e206e28550006442100001e011d00bc52d01e20b828554006442100001e8c0ad090204031200c4055000644210000188c0ad08a20e02d10103e9600064421000018000000000000000000000000000000000000000000000000000000000000000000d2"; + }; + }; +in { config = { # UEFI works here, and variables can be touched @@ -14,8 +30,8 @@ hardware.cpu.intel.updateMicrocode = true; frogeye.desktop = { x11_screens = [ - "HDMI-1-3" - "DVI-I-2-1" + displays.deskLeft.output + displays.deskRight.output ]; maxVideoHeight = 1440; numlock = true; @@ -31,9 +47,41 @@ displaylink = (import displaylinknixpkgs { inherit (super) system; config.allowUnfree = true; }).displaylink; }) ]; - # Needs prefetched binary blobs, see https://nixos.wiki/wiki/Displaylink - services.xserver.videoDrivers = [ "displaylink" "modesetting" ]; - # TODO See if nvidia and DL can work together. + services = { + autorandr = { + profiles = { + portable = { + fingerprint.${displays.embedded.output} = displays.embedded.edid; + config.${displays.embedded.output} = { }; + }; + extOnly = { + fingerprint = { + ${displays.embedded.output} = displays.embedded.edid; + ${displays.deskLeft.output} = displays.deskLeft.edid; + ${displays.deskRight.output} = displays.deskRight.edid; + }; + config = { + ${displays.embedded.output}.enable = false; + ${displays.deskLeft.output} = { + primary = true; + mode = "1920x1200"; + rate = "59.95"; + position = "0x0"; + }; + ${displays.deskRight.output} = { + mode = "1920x1200"; + rate = "59.95"; + position = "1920x0"; + }; + }; + }; + # TODO leftOnly and other things.Might want to abstract a few things first. + }; + }; + # Needs prefetched binary blobs, see https://nixos.wiki/wiki/Displaylink + xserver.videoDrivers = [ "displaylink" "modesetting" ]; + # TODO See if nvidia and DL can work together. + }; }; imports = [ nixos-hardware.nixosModules.dell-g3-3779 diff --git a/hm/desktop/autorandr/default.nix b/hm/desktop/autorandr/default.nix index 21cf210..935dcf0 100644 --- a/hm/desktop/autorandr/default.nix +++ b/hm/desktop/autorandr/default.nix @@ -29,4 +29,3 @@ in services.autorandr.enable = true; }; } -# TODO Deterministic configs? diff --git a/os/default.nix b/os/default.nix index b3307bd..9fe86d9 100644 --- a/os/default.nix +++ b/os/default.nix @@ -7,7 +7,7 @@ ./boot ./ccc ./common.nix - ./desktop.nix + ./desktop ./dev ./diff disko.nixosModules.disko diff --git a/os/desktop/autorandr.nix b/os/desktop/autorandr.nix new file mode 100644 index 0000000..2b87036 --- /dev/null +++ b/os/desktop/autorandr.nix @@ -0,0 +1,21 @@ +{ pkgs, lib, config, ... }: +let + setupScript = "${pkgs.writeShellApplication { + name = "greeter-setup-script"; + runtimeInputs = [ pkgs.autorandr ]; + text = '' + autorandr --change + ''; + }}/bin/greeter-setup-script"; +in +{ + config = { + services = { + autorandr.enable = true; + xserver.displayManager.lightdm.extraConfig = '' + [Seat:*] + display-setup-script = ${setupScript} + ''; + }; + }; +} diff --git a/os/desktop.nix b/os/desktop/default.nix similarity index 97% rename from os/desktop.nix rename to os/desktop/default.nix index d0641ee..1f47bc2 100644 --- a/os/desktop.nix +++ b/os/desktop/default.nix @@ -45,4 +45,7 @@ # So we can use gnome3 pinentry flavour services.dbus.packages = [ pkgs.gcr ]; }; + imports = [ + ./autorandr.nix + ]; } diff --git a/os/qwerty-fr-keypad.diff b/os/desktop/qwerty-fr-keypad.diff similarity index 100% rename from os/qwerty-fr-keypad.diff rename to os/desktop/qwerty-fr-keypad.diff