mpd: set network settings as environment variables
https://mpd.readthedocs.io/en/stable/client.html#connecting-to-mpd These environment variables are picked up by, amongst others, clients based on libmpdclient: -2a42a10067/src/settings.c (L108)-2a42a10067/src/settings.c (L135)
This commit is contained in:
parent
d4e4d5cfa3
commit
2f06b72606
2 changed files with 26 additions and 1 deletions
10
modules/misc/news/2026/01/2026-01-02_00-03-48.nix
Normal file
10
modules/misc/news/2026/01/2026-01-02_00-03-48.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
time = "2026-01-02T00:03:48+00:00";
|
||||
condition = config.services.mpd.enable;
|
||||
message = ''
|
||||
`MPD_HOST` and `MPD_PORT` environment variables are now set automatically.
|
||||
|
||||
This can be disabled with `services.mpd.enableSessionVariables = false`.
|
||||
'';
|
||||
}
|
||||
|
|
@ -22,6 +22,15 @@ in
|
|||
|
||||
package = lib.mkPackageOption pkgs "mpd" { };
|
||||
|
||||
enableSessionVariables = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to set {env}`MPD_HOST` {env}`MPD_PORT` environment variables
|
||||
according to {option}`services.mpd.network`.
|
||||
'';
|
||||
};
|
||||
|
||||
musicDirectory = mkOption {
|
||||
type = with types; either path str;
|
||||
defaultText = lib.literalExpression ''
|
||||
|
|
@ -155,7 +164,13 @@ in
|
|||
);
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
home = {
|
||||
packages = [ cfg.package ];
|
||||
sessionVariables = mkIf cfg.enableSessionVariables {
|
||||
MPD_HOST = mkIf (cfg.network.listenAddress != "any") cfg.network.listenAddress;
|
||||
MPD_PORT = builtins.toString cfg.network.port;
|
||||
};
|
||||
};
|
||||
|
||||
services.mpd = lib.mkMerge [
|
||||
(mkIf (lib.versionAtLeast config.home.stateVersion "22.11" && config.xdg.userDirs.enable) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue