Skip to content

Commit

Permalink
modules/mpd: factor out name & mention man 5 mpd.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Profpatsch committed Feb 18, 2017
1 parent 31dac10 commit 2b0469c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions nixos/modules/services/audio/mpd.nix
Expand Up @@ -4,6 +4,8 @@ with lib;

let

name = "mpd";

uid = config.ids.uids.mpd;
gid = config.ids.gids.mpd;
cfg = config.services.mpd;
Expand Down Expand Up @@ -54,13 +56,14 @@ in {
description = ''
Extra directives added to to the end of MPD's configuration file,
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 {
type = types.path;
default = "/var/lib/mpd";
default = "/var/lib/${name}";
description = ''
The directory where MPD stores its state, tag cache,
playlists etc.
Expand All @@ -69,13 +72,13 @@ in {

user = mkOption {
type = types.str;
default = "mpd";
default = name;
description = "User account under which MPD runs.";
};

group = mkOption {
type = types.str;
default = "mpd";
default = name;
description = "Group account under which MPD runs.";
};

Expand Down Expand Up @@ -131,17 +134,17 @@ in {
};
};

users.extraUsers = optionalAttrs (cfg.user == "mpd") (singleton {
users.extraUsers = optionalAttrs (cfg.user == name) (singleton {
inherit uid;
name = "mpd";
inherit name;
group = cfg.group;
extraGroups = [ "audio" ];
description = "Music Player Daemon user";
home = "${cfg.dataDir}";
});

users.extraGroups = optionalAttrs (cfg.group == "mpd") (singleton {
name = "mpd";
users.extraGroups = optionalAttrs (cfg.group == name) (singleton {
inherit name;
gid = gid;
});
};
Expand Down

0 comments on commit 2b0469c

Please sign in to comment.