modules/mpd: factor out name & mention man 5 mpd.conf

This commit is contained in:
Profpatsch 2017-02-16 01:17:44 +01:00
parent 31dac10c33
commit 2b0469c48f

View file

@ -4,6 +4,8 @@ with lib;
let let
name = "mpd";
uid = config.ids.uids.mpd; uid = config.ids.uids.mpd;
gid = config.ids.gids.mpd; gid = config.ids.gids.mpd;
cfg = config.services.mpd; cfg = config.services.mpd;
@ -54,13 +56,14 @@ in {
description = '' description = ''
Extra directives added to to the end of MPD's configuration file, Extra directives added to to the end of MPD's configuration file,
mpd.conf. Basic configuration like file location and uid/gid mpd.conf. Basic configuration like file location and uid/gid
is added automatically to the beginning of the file. is added automatically to the beginning of the file. For available
options see <literal>man 5 mpd.conf</literal>'.
''; '';
}; };
dataDir = mkOption { dataDir = mkOption {
type = types.path; type = types.path;
default = "/var/lib/mpd"; default = "/var/lib/${name}";
description = '' description = ''
The directory where MPD stores its state, tag cache, The directory where MPD stores its state, tag cache,
playlists etc. playlists etc.
@ -69,13 +72,13 @@ in {
user = mkOption { user = mkOption {
type = types.str; type = types.str;
default = "mpd"; default = name;
description = "User account under which MPD runs."; description = "User account under which MPD runs.";
}; };
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = "mpd"; default = name;
description = "Group account under which MPD runs."; description = "Group account under which MPD runs.";
}; };
@ -131,17 +134,17 @@ in {
}; };
}; };
users.extraUsers = optionalAttrs (cfg.user == "mpd") (singleton { users.extraUsers = optionalAttrs (cfg.user == name) (singleton {
inherit uid; inherit uid;
name = "mpd"; inherit name;
group = cfg.group; group = cfg.group;
extraGroups = [ "audio" ]; extraGroups = [ "audio" ];
description = "Music Player Daemon user"; description = "Music Player Daemon user";
home = "${cfg.dataDir}"; home = "${cfg.dataDir}";
}); });
users.extraGroups = optionalAttrs (cfg.group == "mpd") (singleton { users.extraGroups = optionalAttrs (cfg.group == name) (singleton {
name = "mpd"; inherit name;
gid = gid; gid = gid;
}); });
}; };