nixos/prosody: conditionally provision required directories with StateDirectory
This commit is contained in:
parent
fdb531e995
commit
79bfd3c0d0
|
@ -511,8 +511,13 @@ in
|
|||
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
description = "Directory where Prosody stores its data";
|
||||
default = "/var/lib/prosody";
|
||||
description = ''
|
||||
The prosody home directory used to store all data. If left as the default value
|
||||
this directory will automatically be created before the prosody server starts, otherwise
|
||||
you are responsible for ensuring the directory exists with appropriate ownership
|
||||
and permissions.
|
||||
'';
|
||||
};
|
||||
|
||||
disco_items = mkOption {
|
||||
|
@ -839,9 +844,8 @@ in
|
|||
users.users.prosody = mkIf (cfg.user == "prosody") {
|
||||
uid = config.ids.uids.prosody;
|
||||
description = "Prosody user";
|
||||
createHome = true;
|
||||
inherit (cfg) group;
|
||||
home = "${cfg.dataDir}";
|
||||
home = cfg.dataDir;
|
||||
};
|
||||
|
||||
users.groups.prosody = mkIf (cfg.group == "prosody") {
|
||||
|
@ -854,7 +858,8 @@ in
|
|||
wants = [ "network-online.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
restartTriggers = [ config.environment.etc."prosody/prosody.cfg.lua".source ];
|
||||
serviceConfig = {
|
||||
serviceConfig = mkMerge [
|
||||
{
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
Type = "forking";
|
||||
|
@ -875,7 +880,11 @@ in
|
|||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
};
|
||||
}
|
||||
(mkIf (cfg.dataDir == "/var/lib/prosody") {
|
||||
StateDirectory = "prosody";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue