nixos/unifi: use systemd tmpfiles instead of preStart

This commit is contained in:
Nathan Hawkins 2020-01-24 10:06:29 -05:00
parent 2a8ad18258
commit b0208cb80f

View File

@ -147,8 +147,10 @@ in
}) mountPoints;
systemd.tmpfiles.rules = [
"e '${stateDir}' 0700 unifi - - -"
"d '${stateDir}' 0700 unifi - - -"
"d '${stateDir}/data' 0700 unifi - - -"
"d '${stateDir}/webapps' 0700 unifi - - -"
"L+ '${stateDir}/webapps/ROOT' - - - - ${cfg.unifiPackage}/webapps/ROOT"
];
systemd.services.unifi = {
@ -161,17 +163,6 @@ in
# This a HACK to fix missing dependencies of dynamic libs extracted from jars
environment.LD_LIBRARY_PATH = with pkgs.stdenv; "${cc.cc.lib}/lib";
preStart = ''
# Create the volatile webapps
rm -rf "${stateDir}/webapps"
mkdir -p "${stateDir}/webapps"
ln -s "${cfg.unifiPackage}/webapps/ROOT" "${stateDir}/webapps/ROOT"
'';
postStop = ''
rm -rf "${stateDir}/webapps"
'';
serviceConfig = {
Type = "simple";
ExecStart = "${(removeSuffix "\n" cmd)} start";