From 9bceb8292e9a2c84db999cb5817d77fb8d6b83fe Mon Sep 17 00:00:00 2001 From: Nicolas Berbiche Date: Mon, 17 Jan 2022 16:38:22 -0500 Subject: [PATCH] waybar: fix deprecated "modules" setting check (#2646) - The check did not account the default value of `settings.modules` to be `{}`. The default value was changed to null. - The `settings.modules` option is now hidden from the docs. --- modules/programs/waybar.nix | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/programs/waybar.nix b/modules/programs/waybar.nix index 4c68e3f26..faef644d3 100644 --- a/modules/programs/waybar.nix +++ b/modules/programs/waybar.nix @@ -97,7 +97,8 @@ let modules = mkOption { type = jsonFormat.type; - default = { }; + visible = false; + default = null; description = "Modules configuration."; example = literalExpression '' { @@ -176,19 +177,18 @@ in { modules-left = [ "sway/workspaces" "sway/mode" "wlr/taskbar" ]; modules-center = [ "sway/window" "custom/hello-from-waybar" ]; modules-right = [ "mpd" "custom/mymodule#with-css-id" "temperature" ]; - modules = { - "sway/workspaces" = { - disable-scroll = true; - all-outputs = true; - }; - "custom/hello-from-waybar" = { - format = "hello {}"; - max-length = 40; - interval = "once"; - exec = pkgs.writeShellScript "hello-from-waybar" ''' - echo "from within waybar" - '''; - }; + + "sway/workspaces" = { + disable-scroll = true; + all-outputs = true; + }; + "custom/hello-from-waybar" = { + format = "hello {}"; + max-length = 40; + interval = "once"; + exec = pkgs.writeShellScript "hello-from-waybar" ''' + echo "from within waybar" + '''; }; }; } @@ -244,7 +244,7 @@ in { config = let # Removes nulls because Waybar ignores them. # This is not recursive. - removeNulls = filterAttrs (_: v: v != null); + removeTopLevelNulls = filterAttrs (_: v: v != null); # Makes the actual valid configuration Waybar accepts # (strips our custom settings before converting to JSON) @@ -254,8 +254,8 @@ in { # as its descendants have to live at the top-level settingsWithoutModules = removeAttrs configuration [ "modules" ]; settingsModules = - optionalAttrs (configuration.modules != { }) configuration.modules; - in removeNulls (settingsWithoutModules // settingsModules); + optionalAttrs (configuration.modules != null) configuration.modules; + in removeTopLevelNulls (settingsWithoutModules // settingsModules); # Allow using attrs for settings instead of a list in order to more easily override settings = if builtins.isAttrs cfg.settings then @@ -276,7 +276,7 @@ in { ({ assertion = if lib.versionAtLeast config.home.stateVersion "22.05" then - all (x: !hasAttr "modules" x) settings + all (x: !hasAttr "modules" x || x.modules == null) settings else true; message = ''