From defbb9c5857e157703e8fc7cf3c2ceb01cb95883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nara=20D=C3=ADaz=20Vi=C3=B1olas?= Date: Sat, 9 Dec 2023 13:26:07 +0100 Subject: [PATCH] hyprland: add option sourceFirst Add the option sourceFirst to the hyprland module. When this option is enabled source entries will be put near the top of the file, so that the variables declared in other files can be used by the other configuration entries. Add "source" to the list of important prefixes when the former option is enabled. Resolves #4729 --- modules/misc/news.nix | 17 +++++++++++++++++ modules/services/window-managers/hyprland.nix | 12 +++++++++--- .../window-managers/hyprland/simple-config.conf | 1 + .../window-managers/hyprland/simple-config.nix | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 3e81a55f..bccd511c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1317,6 +1317,23 @@ in A new module is available: 'services.signaturepdf'. ''; } + + { + time = "2023-12-10T08:43:02+00:00"; + condition = config.wayland.windowManager.hyprland.settings ? source; + message = '' + Entries in + + wayland.windowManager.hyprland.settings.source + + are now placed at the start of the configuration file. If you relied + on the previous placement of the 'source' entries, please set + + wayland.windowManager.hyprland.sourceFirst = false + + to keep the previous behaviour. + ''; + } ]; }; } diff --git a/modules/services/window-managers/hyprland.nix b/modules/services/window-managers/hyprland.nix index 5d3ff438..3cd3a4b8 100644 --- a/modules/services/window-managers/hyprland.nix +++ b/modules/services/window-managers/hyprland.nix @@ -175,6 +175,12 @@ in { Extra configuration lines to add to `~/.config/hypr/hyprland.conf`. ''; }; + + sourceFirst = lib.mkEnableOption '' + putting source entries at the top of the configuration + '' // { + default = true; + }; }; config = lib.mkIf cfg.enable { @@ -222,9 +228,9 @@ in { inherit indent; }; allFields = filterAttrs (n: v: !(isAttrs v)) attrs; - importantFields = - filterAttrs (n: _: (hasPrefix "$" n) || (hasPrefix "bezier" n)) - allFields; + importantFields = filterAttrs (n: _: + (hasPrefix "$" n) || (hasPrefix "bezier" n) + || (cfg.sourceFirst && (hasPrefix "source" n))) allFields; fields = builtins.removeAttrs allFields (mapAttrsToList (n: _: n) importantFields); in mkFields importantFields diff --git a/tests/modules/services/window-managers/hyprland/simple-config.conf b/tests/modules/services/window-managers/hyprland/simple-config.conf index 7b745e3a..8d961901 100644 --- a/tests/modules/services/window-managers/hyprland/simple-config.conf +++ b/tests/modules/services/window-managers/hyprland/simple-config.conf @@ -3,6 +3,7 @@ $mod=SUPER bezier=smoothOut, 0.36, 0, 0.66, -0.56 bezier=smoothIn, 0.25, 1, 0.5, 1 bezier=overshot, 0.4,0.8,0.2,1.2 +source=sourced.conf animations { animation=border, 1, 2, smoothIn animation=fade, 1, 4, smoothOut diff --git a/tests/modules/services/window-managers/hyprland/simple-config.nix b/tests/modules/services/window-managers/hyprland/simple-config.nix index ee822755..31fe0432 100644 --- a/tests/modules/services/window-managers/hyprland/simple-config.nix +++ b/tests/modules/services/window-managers/hyprland/simple-config.nix @@ -8,6 +8,8 @@ plugins = [ "/path/to/plugin1" (config.lib.test.mkStubPackage { name = "foo"; }) ]; settings = { + source = [ "sourced.conf" ]; + decoration = { shadow_offset = "0 5"; "col.shadow" = "rgba(00000099)";