Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions nixos/modules/services/audio/mpd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ in
};

openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more ergonomic if we set the type to be either Boolean or some special string that disabled the warning. null is meaningless, especially since its behaviour is not defined in the option description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more ergonomic if we set the type to be either Boolean or some special string that disabled the warning. null is meaningless, especially since its behaviour is not defined in the option description.

I agree. Either with null or a specific string the description will have to be modified. If I'll modify the description to explain the meaning of null would you be satisfied?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever is easiest for you seems good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever is easiest for you seems good to me.

Done.

description = "Open ports in the firewall for mpd.";
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Open ports in the firewall for mpd. If `null` (default), you might
get a warning asking you to set it explicitly to `true` or `false`,
depending upon the value of `services.mpd.settings.bind_to_address`.
'';
};

settings = lib.mkOption {
Expand Down Expand Up @@ -378,9 +382,9 @@ in
])
|| (lib.hasPrefix "/" cfg.settings.bind_to_address)
)
&& !cfg.openFirewall
&& (isNull cfg.openFirewall)
)
"Using '${cfg.settings.bind_to_address}' as services.mpd.settings.bind_to_address without enabling services.mpd.openFirewall, might prevent you from accessing MPD from other clients.";
"Using '${cfg.settings.bind_to_address}' as services.mpd.settings.bind_to_address without enabling services.mpd.openFirewall, might prevent you from accessing MPD from other clients. To suppress this warning, set services.mpd.openFirewall explicitly to `false`";

# install mpd units
systemd.packages = [ pkgs.mpd ];
Expand Down Expand Up @@ -438,7 +442,9 @@ in
};
};

networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ cfg.settings.port ];
networking.firewall.allowedTCPPorts = lib.optionals (
builtins.isBool cfg.openFirewall && cfg.openFirewall
) [ cfg.settings.port ];

users.users = lib.optionalAttrs (cfg.user == name) {
${name} = {
Expand Down
Loading