1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 19:29:47 +01:00

hyprland: change plugins settings generation

The previous syntax (`plugin:name { ...settings}`) is not working with
more than one plugin. There is no documentation for this, just the
source code [1].

With this update the plugins paths aren't generated together with the
full config (so the "plugin" field is not "important" anymore) and the
plugins settings are generated like the other fields.

[1] 4d403dac32/src/config/ConfigManager.cpp (L1574)
This commit is contained in:
Samuele Facenda 2024-01-21 00:40:55 +01:00 committed by Mikilio
parent 1061543033
commit 65bebc010e
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
2 changed files with 24 additions and 21 deletions

View file

@ -199,19 +199,8 @@ in {
home.packages = lib.optional (cfg.package != null) cfg.finalPackage; home.packages = lib.optional (cfg.package != null) cfg.finalPackage;
xdg.configFile."hypr/hyprland.conf" = let 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 != "" shouldGenerate = cfg.systemd.enable || cfg.extraConfig != ""
|| combinedSettings != { }; || cfg.settings != { } || cfg.plugins != [ ];
toHyprconf = with lib; toHyprconf = with lib;
attrs: indentLevel: attrs: indentLevel:
@ -230,17 +219,29 @@ in {
}; };
allFields = filterAttrs (n: v: !(isAttrs v)) attrs; allFields = filterAttrs (n: v: !(isAttrs v)) attrs;
importantFields = filterAttrs (n: _: importantFields = filterAttrs (n: _:
(hasPrefix "$" n) || (hasPrefix "bezier" n) || (n == "plugin") (hasPrefix "$" n) || (hasPrefix "bezier" n)
|| (cfg.sourceFirst && (hasPrefix "source" n))) allFields; || (cfg.sourceFirst && (hasPrefix "source" n))) allFields;
fields = builtins.removeAttrs allFields fields = builtins.removeAttrs allFields
(mapAttrsToList (n: _: n) importantFields); (mapAttrsToList (n: _: n) importantFields);
in mkFields importantFields in mkFields importantFields
+ concatStringsSep "\n" (mapAttrsToList mkSection sections) + concatStringsSep "\n" (mapAttrsToList mkSection sections)
+ mkFields fields; + 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 { in lib.mkIf shouldGenerate {
text = lib.optionalString cfg.systemd.enable systemdActivation text = lib.optionalString cfg.systemd.enable systemdActivation
+ lib.optionalString (combinedSettings != { }) + lib.optionalString (cfg.plugins != [ ])
(toHyprconf combinedSettings 0) (pluginsToHyprconf cfg.plugins)
+ lib.optionalString (cfg.settings != { }) (toHyprconf cfg.settings 0)
+ lib.optionalString (cfg.extraConfig != "") cfg.extraConfig; + lib.optionalString (cfg.extraConfig != "") cfg.extraConfig;
onChange = lib.mkIf (cfg.package != null) '' onChange = lib.mkIf (cfg.package != null) ''

View file

@ -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 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 $mod=SUPER
bezier=smoothOut, 0.36, 0, 0.66, -0.56 bezier=smoothOut, 0.36, 0, 0.66, -0.56
bezier=smoothIn, 0.25, 1, 0.5, 1 bezier=smoothIn, 0.25, 1, 0.5, 1
bezier=overshot, 0.4,0.8,0.2,1.2 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 source=sourced.conf
animations { animations {
animation=border, 1, 2, smoothIn animation=border, 1, 2, smoothIn
@ -27,11 +27,13 @@ input {
kb_layout=ro kb_layout=ro
} }
plugin:plugin1 { plugin {
section { plugin1 {
other=dummy setting section {
other=dummy setting
}
dummy=plugin setting
} }
dummy=plugin setting
} }
bindm=$mod, mouse:272, movewindow bindm=$mod, mouse:272, movewindow
bindm=$mod, mouse:273, resizewindow bindm=$mod, mouse:273, resizewindow