diff --git a/flake.lock b/flake.lock index 1ee373c..ff6f09c 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1778716662, - "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "lastModified": 1782949081, + "narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e", "type": "github" }, "original": { @@ -37,11 +37,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1779560665, - "narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=", + "lastModified": 1782723713, + "narHash": "sha256-oPXCU/SSUokcGaJREHibG1CBX3+s/W7orDWQOZDsEeQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786", + "rev": "b5aa0fbd538984f6e3d201be0005b4463d8b09f8", "type": "github" }, "original": { diff --git a/lib/default.nix b/lib/default.nix index 6c170e9..1eef53e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -25,6 +25,7 @@ in { mkHylixLines mkHylixLuaCall mkHylixLuaCallLines + mkHylixLuaSection mkHylixLuaValueCall mkHylixMonitorLine mkHylixRuleLine diff --git a/lib/modules/core.nix b/lib/modules/core.nix index 0eb9958..d6b060f 100644 --- a/lib/modules/core.nix +++ b/lib/modules/core.nix @@ -6,14 +6,21 @@ filterAttrs mkIf mkOrder + optionalString # keep-sorted end ; in rec { cleanAttrs = filterAttrs (_: value: value != null); - mkHylixGeneratedConfig = condition: order: text: + mkHylixLuaSection = name: text: + optionalString (text != "") '' + -- ${name} + ${text} + ''; + + mkHylixGeneratedConfig = condition: order: name: text: mkIf condition { - programs.hylix._generatedConfig = mkOrder order text; + programs.hylix._generatedConfig = mkOrder order (mkHylixLuaSection name text); }; mkHylixLines = lineFn: values: diff --git a/modules/hylix/animations.nix b/modules/hylix/animations.nix index fa024b8..2be2c5a 100644 --- a/modules/hylix/animations.nix +++ b/modules/hylix/animations.nix @@ -152,9 +152,9 @@ _: { }; config = mkMerge [ - (mkHylixGeneratedConfig (cfg.animations.curves != {}) ordering.curves curveLines) + (mkHylixGeneratedConfig (cfg.animations.curves != {}) ordering.curves "animations.curves" curveLines) - (mkHylixGeneratedConfig (cfg.animations.animations != []) ordering.animations animLines) + (mkHylixGeneratedConfig (cfg.animations.animations != []) ordering.animations "animations.animations" animLines) ]; }; } diff --git a/modules/hylix/autostart.nix b/modules/hylix/autostart.nix index 83b2d96..adf2945 100644 --- a/modules/hylix/autostart.nix +++ b/modules/hylix/autostart.nix @@ -61,6 +61,6 @@ _: { default = []; }; - config = mkHylixGeneratedConfig (cfg.autostart != []) ordering.autostart lines; + config = mkHylixGeneratedConfig (cfg.autostart != []) ordering.autostart "autostart" lines; }; } diff --git a/modules/hylix/binds.nix b/modules/hylix/binds.nix index f6d3f6d..a40a9e6 100644 --- a/modules/hylix/binds.nix +++ b/modules/hylix/binds.nix @@ -149,6 +149,6 @@ default = []; }; - config = mkHylixGeneratedConfig (allBinds != []) ordering.binds (concatStringsSep "\n" lines); + config = mkHylixGeneratedConfig (allBinds != []) ordering.binds "binds" (concatStringsSep "\n" lines); }; } diff --git a/modules/hylix/devices.nix b/modules/hylix/devices.nix index c0bdf82..f034f75 100644 --- a/modules/hylix/devices.nix +++ b/modules/hylix/devices.nix @@ -40,6 +40,6 @@ _: { default = []; }; - config = mkHylixGeneratedConfig (cfg.devices != []) ordering.devices lines; + config = mkHylixGeneratedConfig (cfg.devices != []) ordering.devices "devices" lines; }; } diff --git a/modules/hylix/env.nix b/modules/hylix/env.nix index 45ff172..2b68838 100644 --- a/modules/hylix/env.nix +++ b/modules/hylix/env.nix @@ -39,6 +39,6 @@ _: { default = {}; }; - config = mkHylixGeneratedConfig (cfg.env != {}) ordering.env envLines; + config = mkHylixGeneratedConfig (cfg.env != {}) ordering.env "env" envLines; }; } diff --git a/modules/hylix/events.nix b/modules/hylix/events.nix index 99bce7c..a9f426d 100644 --- a/modules/hylix/events.nix +++ b/modules/hylix/events.nix @@ -65,6 +65,6 @@ _: { default = []; }; - config = mkHylixGeneratedConfig (cfg.events != []) ordering.events lines; + config = mkHylixGeneratedConfig (cfg.events != []) ordering.events "events" lines; }; } diff --git a/modules/hylix/extraLua.nix b/modules/hylix/extraLua.nix index 7016082..6ad4959 100644 --- a/modules/hylix/extraLua.nix +++ b/modules/hylix/extraLua.nix @@ -53,7 +53,7 @@ _: { }; } - (mkHylixGeneratedConfig (cfg.extraLua != "") ordering.extraLua cfg.extraLua) + (mkHylixGeneratedConfig (cfg.extraLua != "") ordering.extraLua "extraLua" cfg.extraLua) ]; }; } diff --git a/modules/hylix/gestures.nix b/modules/hylix/gestures.nix index 1dd98f3..872cc25 100644 --- a/modules/hylix/gestures.nix +++ b/modules/hylix/gestures.nix @@ -40,6 +40,6 @@ _: { default = []; }; - config = mkHylixGeneratedConfig (cfg.gestures != []) ordering.gestures lines; + config = mkHylixGeneratedConfig (cfg.gestures != []) ordering.gestures "gestures" lines; }; } diff --git a/modules/hylix/monitors.nix b/modules/hylix/monitors.nix index f875eb1..a3a2149 100644 --- a/modules/hylix/monitors.nix +++ b/modules/hylix/monitors.nix @@ -87,6 +87,6 @@ _: { default = []; }; - config = mkHylixGeneratedConfig (cfg.monitors != []) ordering.monitors lines; + config = mkHylixGeneratedConfig (cfg.monitors != []) ordering.monitors "monitors" lines; }; } diff --git a/modules/hylix/notifications.nix b/modules/hylix/notifications.nix index bad3e07..d1a4d47 100644 --- a/modules/hylix/notifications.nix +++ b/modules/hylix/notifications.nix @@ -72,6 +72,6 @@ _: { default = []; }; - config = mkHylixGeneratedConfig (cfg.notifications != []) ordering.notifications lines; + config = mkHylixGeneratedConfig (cfg.notifications != []) ordering.notifications "notifications" lines; }; } diff --git a/modules/hylix/permissions.nix b/modules/hylix/permissions.nix index 063f0c6..42af93e 100644 --- a/modules/hylix/permissions.nix +++ b/modules/hylix/permissions.nix @@ -66,6 +66,6 @@ _: { default = []; }; - config = mkHylixGeneratedConfig (cfg.permissions != []) ordering.permissions lines; + config = mkHylixGeneratedConfig (cfg.permissions != []) ordering.permissions "permissions" lines; }; } diff --git a/modules/hylix/rules.nix b/modules/hylix/rules.nix index 2a259b1..80d9714 100644 --- a/modules/hylix/rules.nix +++ b/modules/hylix/rules.nix @@ -37,25 +37,29 @@ _: { { func = "hl.window_rule"; order = ordering.windowRules; + section = "rules.window"; values = cfg.rules.window; } { func = "hl.workspace_rule"; order = ordering.workspaceRules; + section = "rules.workspace"; values = cfg.rules.workspace; } { func = "hl.layer_rule"; order = ordering.layerRules; + section = "rules.layer"; values = cfg.rules.layer; } ]; mkRuleSection = { func, order, + section, values, }: - mkHylixGeneratedConfig (values != []) order (mkHylixLines (buildRule func) values); + mkHylixGeneratedConfig (values != []) order section (mkHylixLines (buildRule func) values); in { options.programs.hylix.rules = { # keep-sorted start block=yes newline_separated=yes diff --git a/modules/hylix/settings.nix b/modules/hylix/settings.nix index 26a2f5c..ca3c008 100644 --- a/modules/hylix/settings.nix +++ b/modules/hylix/settings.nix @@ -35,6 +35,7 @@ _: { mkHylixGeneratedConfig (cfg.settings != {}) ordering.settings + "settings" (mkHylixLuaValueCall toLua "hl.config" [cfg.settings]); }; }