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