Optional user and group to run the MPD
This commit is contained in:
parent
0fd3db4ba1
commit
581a90bad8
1 changed files with 21 additions and 8 deletions
|
@ -15,6 +15,8 @@ let
|
|||
state_file "${cfg.dataDir}/state"
|
||||
sticker_file "${cfg.dataDir}/sticker.sql"
|
||||
log_file "syslog"
|
||||
user "${cfg.user}"
|
||||
group "${cfg.group}"
|
||||
${if cfg.network.host != "any" then
|
||||
"bind_to_address ${cfg.network.host}" else ""}
|
||||
${if cfg.network.port != 6600 then
|
||||
|
@ -40,8 +42,7 @@ in {
|
|||
musicDirectory = mkOption {
|
||||
default = "${cfg.dataDir}/music";
|
||||
description = ''
|
||||
Extra configuration added to the end of MPD's
|
||||
configuration file, mpd.conf.
|
||||
The directory where mpd reads music from.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -62,6 +63,16 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "mpd";
|
||||
description = "User account under which MPD runs.";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
default = "mpd";
|
||||
description = "Group account under which MPD runs.";
|
||||
};
|
||||
|
||||
network = {
|
||||
|
||||
host = mkOption {
|
||||
|
@ -96,7 +107,7 @@ in {
|
|||
description = "Music Player Daemon";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.mpd ];
|
||||
preStart = "mkdir -p ${cfg.dataDir} && chown -R mpd:mpd ${cfg.dataDir}";
|
||||
preStart = "mkdir -p ${cfg.dataDir} && chown -R ${cfg.user}:${cfg.group} ${cfg.dataDir}";
|
||||
script = "exec mpd --no-daemon ${mpdConf}";
|
||||
serviceConfig = {
|
||||
User = "mpd";
|
||||
|
@ -104,16 +115,18 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
users.extraUsers.mpd = {
|
||||
users.extraUsers = optionalAttrs (cfg.user == "mpd") (singleton {
|
||||
inherit uid;
|
||||
group = "mpd";
|
||||
name = "mpd";
|
||||
group = cfg.group;
|
||||
extraGroups = [ "audio" ];
|
||||
description = "Music Player Daemon user";
|
||||
home = "${cfg.dataDir}";
|
||||
};
|
||||
|
||||
users.extraGroups.mpd.gid = gid;
|
||||
});
|
||||
|
||||
users.extraGroups = optionalAttrs (cfg.group == "mpd") (singleton {
|
||||
gid = gid;
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue