From e3c26ec8311dd32d0d7363ed9cf69014078ffb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Tue, 2 Sep 2025 18:27:58 +0800 Subject: [PATCH] vanadium: minor refactor display config --- nix/configurations/vanadium/nixos/display.nix | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/nix/configurations/vanadium/nixos/display.nix b/nix/configurations/vanadium/nixos/display.nix index 95b8e649..012b297f 100644 --- a/nix/configurations/vanadium/nixos/display.nix +++ b/nix/configurations/vanadium/nixos/display.nix @@ -41,13 +41,11 @@ allDevices = ["eDP-1"] ++ allExternDevices; - /** - TODO: merge when upstream is merged - https://github.com/NixOS/nixpkgs/pull/436434 - - Generate an attribute set by mapping a function over a list of attribute names. - It allows setting the name of the attribute. - */ + # TODO: merge when upstream is merged + # https://github.com/NixOS/nixpkgs/pull/436434 + # + # Generate an attribute set by mapping a function over a list of attribute names. + # It allows setting the name of the attribute. genAttrs' = xs: func: builtins.listToAttrs (map func xs); mkDpiSwitch = {dpi}: { @@ -57,6 +55,7 @@ ''}"; }; + # Is scoped to an output device, no need to be called on built-in display mkBrightnessSwitch = { device, brightness, @@ -69,10 +68,7 @@ # Note: the "position" field corresponds to the "pos" field outputted by autorandr # To get the current config, run `xrandr --auto` and then `autorandr --config` configs = { - allOff = genAttrs' allDevices (name: { - inherit name; - value = {enable = false;}; - }); + allOff = lib.genAttrs allDevices (_: {enable = false;}); enableBuiltin = { eDP-1 = { enable = true; @@ -96,8 +92,7 @@ frameworkBuiltin = { fingerprint.eDP-1 = built-in; - config = with configs; - allOff // enableBuiltin; + config = with configs; allOff // enableBuiltin; hooks.postswitch = mkDpiSwitch {dpi = 150;}; }; @@ -106,8 +101,7 @@ ${name} = asus-monitor; eDP-1 = built-in; }; - config = with configs; - allOff // enableDevice name; + config = with configs; allOff // enableDevice name; hooks.postswitch = mkDpiSwitch {dpi = 110;} // mkBrightnessSwitch { @@ -117,9 +111,6 @@ }; in {default = frameworkBuiltin;} - // genAttrs' allExternDevices (name: { - name = "asus-${name}"; - value = mkAsusProfile name; - }); + // genAttrs' allExternDevices (name: lib.nameValuePair "asus-${name}" (mkAsusProfile name)); }; }