diff --git a/modules/services/window-managers/hyprland.nix b/modules/services/window-managers/hyprland.nix index d677eda7..65cf0c31 100644 --- a/modules/services/window-managers/hyprland.nix +++ b/modules/services/window-managers/hyprland.nix @@ -199,19 +199,8 @@ in { home.packages = lib.optional (cfg.package != null) cfg.finalPackage; xdg.configFile."hypr/hyprland.conf" = let - combinedSettings = cfg.settings // { - plugin = let - mkEntry = entry: - if lib.types.package.check entry then - "${entry}/lib/lib${entry.pname}.so" - else - entry; - in map mkEntry cfg.plugins; - } // lib.mapAttrs' (n: v: lib.nameValuePair "plugin:${n}" v) - (lib.attrByPath [ "plugin" ] { } cfg.settings); - shouldGenerate = cfg.systemd.enable || cfg.extraConfig != "" - || combinedSettings != { }; + || cfg.settings != { } || cfg.plugins != [ ]; toHyprconf = with lib; attrs: indentLevel: @@ -230,17 +219,29 @@ in { }; allFields = filterAttrs (n: v: !(isAttrs v)) attrs; importantFields = filterAttrs (n: _: - (hasPrefix "$" n) || (hasPrefix "bezier" n) || (n == "plugin") + (hasPrefix "$" n) || (hasPrefix "bezier" n) || (cfg.sourceFirst && (hasPrefix "source" n))) allFields; fields = builtins.removeAttrs allFields (mapAttrsToList (n: _: n) importantFields); in mkFields importantFields + concatStringsSep "\n" (mapAttrsToList mkSection sections) + mkFields fields; + + pluginsToHyprconf = plugins: + toHyprconf { + plugin = let + mkEntry = entry: + if lib.types.package.check entry then + "${entry}/lib/lib${entry.pname}.so" + else + entry; + in map mkEntry cfg.plugins; + } 0; in lib.mkIf shouldGenerate { text = lib.optionalString cfg.systemd.enable systemdActivation - + lib.optionalString (combinedSettings != { }) - (toHyprconf combinedSettings 0) + + lib.optionalString (cfg.plugins != [ ]) + (pluginsToHyprconf cfg.plugins) + + lib.optionalString (cfg.settings != { }) (toHyprconf cfg.settings 0) + lib.optionalString (cfg.extraConfig != "") cfg.extraConfig; onChange = lib.mkIf (cfg.package != null) '' diff --git a/tests/modules/services/window-managers/hyprland/simple-config.conf b/tests/modules/services/window-managers/hyprland/simple-config.conf index 4df74413..0db599a3 100644 --- a/tests/modules/services/window-managers/hyprland/simple-config.conf +++ b/tests/modules/services/window-managers/hyprland/simple-config.conf @@ -1,10 +1,10 @@ exec-once = /nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target +plugin=/path/to/plugin1 +plugin=/nix/store/00000000000000000000000000000000-foo/lib/libfoo.so $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 -plugin=/path/to/plugin1 -plugin=/nix/store/00000000000000000000000000000000-foo/lib/libfoo.so source=sourced.conf animations { animation=border, 1, 2, smoothIn @@ -27,11 +27,13 @@ input { kb_layout=ro } -plugin:plugin1 { - section { - other=dummy setting +plugin { + plugin1 { + section { + other=dummy setting + } + dummy=plugin setting } - dummy=plugin setting } bindm=$mod, mouse:272, movewindow bindm=$mod, mouse:273, resizewindow