about summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/apache-httpd
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2020-01-28 19:29:14 -0500
committerAaron Andersen <aaron@fosslib.net>2020-01-31 20:39:25 -0500
commit02247205624a3fc260764cba954e75989775ec86 (patch)
tree4e4a6cdc780410f7c6d286858f351be728b1bbfa /nixos/modules/services/web-servers/apache-httpd
parent01ccb67598f8a475bee13c97d90a6d95013ab5ce (diff)
nixos/httpd: provision log directory with tmpfiles instead of mkdir
Diffstat (limited to 'nixos/modules/services/web-servers/apache-httpd')
-rw-r--r--nixos/modules/services/web-servers/apache-httpd/default.nix12
1 files changed, 10 insertions, 2 deletions
diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix
index 2452ca20b05c1..3200a26364f68 100644
--- a/nixos/modules/services/web-servers/apache-httpd/default.nix
+++ b/nixos/modules/services/web-servers/apache-httpd/default.nix
@@ -681,6 +681,15 @@ in
       "access_compat"
     ];
 
+    systemd.tmpfiles.rules =
+      let
+        svc = config.systemd.services.httpd.serviceConfig;
+      in
+        [
+          "d '${cfg.logDir}' 0700 ${svc.User} ${svc.Group}"
+          "Z '${cfg.logDir}' - ${svc.User} ${svc.Group}"
+        ];
+
     systemd.services.httpd =
       let
         vhostsACME = filter (hostOpts: hostOpts.enableACME) vhosts;
@@ -701,8 +710,6 @@ in
 
         preStart =
           ''
-            mkdir -m 0700 -p ${cfg.logDir}
-
             # Get rid of old semaphores.  These tend to accumulate across
             # server restarts, eventually preventing it from restarting
             # successfully.
@@ -715,6 +722,7 @@ in
           ExecStart = "@${pkg}/bin/httpd httpd -f ${httpdConf}";
           ExecStop = "${pkg}/bin/httpd -f ${httpdConf} -k graceful-stop";
           ExecReload = "${pkg}/bin/httpd -f ${httpdConf} -k graceful";
+          User = "root";
           Group = cfg.group;
           Type = "forking";
           PIDFile = "${runtimeDir}/httpd.pid";