summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/apache-httpd/default.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-18 17:00:24 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-18 18:04:17 +0100
commit886b9e27a6a34f714eca5f5e750884a1ac57e810 (patch)
treee967253219de0335471b1d522ee0d6fb0d007747 /nixos/modules/services/web-servers/apache-httpd/default.nix
parent2b0aea17934fda4aca24d4b6b99f0b9c24486ff7 (diff)
downloadnixlib-886b9e27a6a34f714eca5f5e750884a1ac57e810.tar
nixlib-886b9e27a6a34f714eca5f5e750884a1ac57e810.tar.gz
nixlib-886b9e27a6a34f714eca5f5e750884a1ac57e810.tar.bz2
nixlib-886b9e27a6a34f714eca5f5e750884a1ac57e810.tar.lz
nixlib-886b9e27a6a34f714eca5f5e750884a1ac57e810.tar.xz
nixlib-886b9e27a6a34f714eca5f5e750884a1ac57e810.tar.zst
nixlib-886b9e27a6a34f714eca5f5e750884a1ac57e810.zip
httpd.nix: Support non-root operation
Diffstat (limited to 'nixos/modules/services/web-servers/apache-httpd/default.nix')
-rw-r--r--nixos/modules/services/web-servers/apache-httpd/default.nix5
1 files changed, 3 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 900948893489..cdb42fa7308a 100644
--- a/nixos/modules/services/web-servers/apache-httpd/default.nix
+++ b/nixos/modules/services/web-servers/apache-httpd/default.nix
@@ -628,10 +628,10 @@ in
         preStart =
           ''
             mkdir -m 0750 -p ${mainCfg.stateDir}
-            chown root.${mainCfg.group} ${mainCfg.stateDir}
+            [ $(id -u) != 0 ] || chown root.${mainCfg.group} ${mainCfg.stateDir}
             ${optionalString version24 ''
               mkdir -m 0750 -p "${mainCfg.stateDir}/runtime"
-              chown root.${mainCfg.group} "${mainCfg.stateDir}/runtime"
+              [ $(id -u) != 0 ] || chown root.${mainCfg.group} "${mainCfg.stateDir}/runtime"
             ''}
             mkdir -m 0700 -p ${mainCfg.logDir}
 
@@ -659,6 +659,7 @@ in
         serviceConfig.ExecStart = "@${httpd}/bin/httpd httpd -f ${httpdConf}";
         serviceConfig.ExecStop = "${httpd}/bin/httpd -f ${httpdConf} -k graceful-stop";
         serviceConfig.Type = "forking";
+        serviceConfig.PIDFile = "${mainCfg.stateDir}/httpd.pid";
         serviceConfig.Restart = "always";
       };