Merge pull request #38820 from brainrape/nixos-prosody-add-user-group

nixos/prosody: add user/group options, fix pidfile path
This commit is contained in:
Robert Schütz 2018-04-13 11:55:10 +02:00 committed by GitHub
commit 3ea1f1dd8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -301,6 +301,18 @@ in
default = "/var/lib/prosody";
};
user = mkOption {
type = types.str;
default = "prosody";
description = "User account under which prosody runs.";
};
group = mkOption {
type = types.str;
default = "prosody";
description = "Group account under which prosody runs.";
};
allowRegistration = mkOption {
type = types.bool;
default = false;
@ -427,7 +439,7 @@ in
environment.etc."prosody/prosody.cfg.lua".text = ''
pidfile = "${cfg.dataDir}/prosody.pid"
pidfile = "/run/prosody/prosody.pid"
log = "*syslog"
@ -475,15 +487,15 @@ in
'') cfg.virtualHosts) }
'';
users.extraUsers.prosody = {
users.extraUsers.prosody = mkIf (cfg.user == "prosody") {
uid = config.ids.uids.prosody;
description = "Prosody user";
createHome = true;
group = "prosody";
inherit (cfg) group;
home = "${cfg.dataDir}";
};
users.extraGroups.prosody = {
users.extraGroups.prosody = mkIf (cfg.group == "prosody") {
gid = config.ids.gids.prosody;
};
@ -494,9 +506,11 @@ in
wantedBy = [ "multi-user.target" ];
restartTriggers = [ config.environment.etc."prosody/prosody.cfg.lua".source ];
serviceConfig = {
User = "prosody";
User = cfg.user;
Group = cfg.group;
Type = "forking";
PIDFile = "${cfg.dataDir}/prosody.pid";
RuntimeDirectory = [ "prosody" ];
PIDFile = "/run/prosody/prosody.pid";
ExecStart = "${cfg.package}/bin/prosodyctl start";
};
};