1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-28 01:18:32 +02: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 GitHub
parent ce4b88c465
commit 9b378afae7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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;
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) ''

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
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