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"
|
state_file "${cfg.dataDir}/state"
|
||||||
sticker_file "${cfg.dataDir}/sticker.sql"
|
sticker_file "${cfg.dataDir}/sticker.sql"
|
||||||
log_file "syslog"
|
log_file "syslog"
|
||||||
|
user "${cfg.user}"
|
||||||
|
group "${cfg.group}"
|
||||||
${if cfg.network.host != "any" then
|
${if cfg.network.host != "any" then
|
||||||
"bind_to_address ${cfg.network.host}" else ""}
|
"bind_to_address ${cfg.network.host}" else ""}
|
||||||
${if cfg.network.port != 6600 then
|
${if cfg.network.port != 6600 then
|
||||||
|
@ -40,8 +42,7 @@ in {
|
||||||
musicDirectory = mkOption {
|
musicDirectory = mkOption {
|
||||||
default = "${cfg.dataDir}/music";
|
default = "${cfg.dataDir}/music";
|
||||||
description = ''
|
description = ''
|
||||||
Extra configuration added to the end of MPD's
|
The directory where mpd reads music from.
|
||||||
configuration file, mpd.conf.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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 = {
|
network = {
|
||||||
|
|
||||||
host = mkOption {
|
host = mkOption {
|
||||||
|
@ -96,7 +107,7 @@ in {
|
||||||
description = "Music Player Daemon";
|
description = "Music Player Daemon";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ pkgs.mpd ];
|
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}";
|
script = "exec mpd --no-daemon ${mpdConf}";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "mpd";
|
User = "mpd";
|
||||||
|
@ -104,16 +115,18 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
users.extraUsers.mpd = {
|
users.extraUsers = optionalAttrs (cfg.user == "mpd") (singleton {
|
||||||
inherit uid;
|
inherit uid;
|
||||||
group = "mpd";
|
name = "mpd";
|
||||||
|
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.mpd.gid = gid;
|
|
||||||
|
|
||||||
|
users.extraGroups = optionalAttrs (cfg.group == "mpd") (singleton {
|
||||||
|
gid = gid;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue