1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

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.
This commit is contained in:
Nicolas Berbiche 2022-01-17 16:38:22 -05:00 committed by GitHub
parent 60d2c9660b
commit 9bceb8292e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,7 +97,8 @@ let
modules = mkOption { modules = mkOption {
type = jsonFormat.type; type = jsonFormat.type;
default = { }; visible = false;
default = null;
description = "Modules configuration."; description = "Modules configuration.";
example = literalExpression '' example = literalExpression ''
{ {
@ -176,19 +177,18 @@ in {
modules-left = [ "sway/workspaces" "sway/mode" "wlr/taskbar" ]; modules-left = [ "sway/workspaces" "sway/mode" "wlr/taskbar" ];
modules-center = [ "sway/window" "custom/hello-from-waybar" ]; modules-center = [ "sway/window" "custom/hello-from-waybar" ];
modules-right = [ "mpd" "custom/mymodule#with-css-id" "temperature" ]; modules-right = [ "mpd" "custom/mymodule#with-css-id" "temperature" ];
modules = {
"sway/workspaces" = { "sway/workspaces" = {
disable-scroll = true; disable-scroll = true;
all-outputs = true; all-outputs = true;
}; };
"custom/hello-from-waybar" = { "custom/hello-from-waybar" = {
format = "hello {}"; format = "hello {}";
max-length = 40; max-length = 40;
interval = "once"; interval = "once";
exec = pkgs.writeShellScript "hello-from-waybar" ''' exec = pkgs.writeShellScript "hello-from-waybar" '''
echo "from within waybar" echo "from within waybar"
'''; ''';
};
}; };
}; };
} }
@ -244,7 +244,7 @@ in {
config = let config = let
# Removes nulls because Waybar ignores them. # Removes nulls because Waybar ignores them.
# This is not recursive. # This is not recursive.
removeNulls = filterAttrs (_: v: v != null); removeTopLevelNulls = filterAttrs (_: v: v != null);
# Makes the actual valid configuration Waybar accepts # Makes the actual valid configuration Waybar accepts
# (strips our custom settings before converting to JSON) # (strips our custom settings before converting to JSON)
@ -254,8 +254,8 @@ in {
# as its descendants have to live at the top-level # as its descendants have to live at the top-level
settingsWithoutModules = removeAttrs configuration [ "modules" ]; settingsWithoutModules = removeAttrs configuration [ "modules" ];
settingsModules = settingsModules =
optionalAttrs (configuration.modules != { }) configuration.modules; optionalAttrs (configuration.modules != null) configuration.modules;
in removeNulls (settingsWithoutModules // settingsModules); in removeTopLevelNulls (settingsWithoutModules // settingsModules);
# Allow using attrs for settings instead of a list in order to more easily override # Allow using attrs for settings instead of a list in order to more easily override
settings = if builtins.isAttrs cfg.settings then settings = if builtins.isAttrs cfg.settings then
@ -276,7 +276,7 @@ in {
({ ({
assertion = assertion =
if lib.versionAtLeast config.home.stateVersion "22.05" then 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 else
true; true;
message = '' message = ''