1 --- /nix/store/xj651aslybfsma20hpbi5nznfcffq8ky-nixexprs.tar.xz/nixos/modules/services/web-servers/apache-httpd/default.nix 1970-01-01 01:00:01.000000000 +0100
2 +++ modules/websites/httpd-service-builder.nix 2020-04-04 03:08:29.068490345 +0200
4 +# to help backporting this builder should stay as close as possible to
5 +# nixos/modules/services/web-servers/apache-httpd/default.nix
6 +{ httpdName, withUsers ? true }:
7 { config, lib, pkgs, ... }:
13 - cfg = config.services.httpd;
14 + cfg = config.services.httpd."${httpdName}";
16 - runtimeDir = "/run/httpd";
17 + runtimeDir = "/run/httpd_${httpdName}";
19 pkg = cfg.package.out;
25 - # But do allow access to files in the store so that we don't have
26 - # to generate <Directory> clauses for every generated file that we
28 - <Directory /nix/store>
34 ${concatMapStringsSep "\n" mkVHostConf vhosts}
39 - (mkRemovedOptionModule [ "services" "httpd" "extraSubservices" ] "Most existing subservices have been ported to the NixOS module system. Please update your configuration accordingly.")
40 - (mkRemovedOptionModule [ "services" "httpd" "stateDir" ] "The httpd module now uses /run/httpd as a runtime directory.")
41 + (mkRemovedOptionModule [ "services" "httpd" httpdName "extraSubservices" ] "Most existing subservices have been ported to the NixOS module system. Please update your configuration accordingly.")
42 + (mkRemovedOptionModule [ "services" "httpd" httpdName "stateDir" ] "The httpd module now uses /run/httpd as a runtime directory.")
44 # virtualHosts options
45 - (mkRemovedOptionModule [ "services" "httpd" "documentRoot" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
46 - (mkRemovedOptionModule [ "services" "httpd" "enableSSL" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
47 - (mkRemovedOptionModule [ "services" "httpd" "enableUserDir" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
48 - (mkRemovedOptionModule [ "services" "httpd" "globalRedirect" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
49 - (mkRemovedOptionModule [ "services" "httpd" "hostName" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
50 - (mkRemovedOptionModule [ "services" "httpd" "listen" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
51 - (mkRemovedOptionModule [ "services" "httpd" "robotsEntries" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
52 - (mkRemovedOptionModule [ "services" "httpd" "servedDirs" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
53 - (mkRemovedOptionModule [ "services" "httpd" "servedFiles" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
54 - (mkRemovedOptionModule [ "services" "httpd" "serverAliases" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
55 - (mkRemovedOptionModule [ "services" "httpd" "sslServerCert" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
56 - (mkRemovedOptionModule [ "services" "httpd" "sslServerChain" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
57 - (mkRemovedOptionModule [ "services" "httpd" "sslServerKey" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
58 + (mkRemovedOptionModule [ "services" "httpd" httpdName "documentRoot" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
59 + (mkRemovedOptionModule [ "services" "httpd" httpdName "enableSSL" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
60 + (mkRemovedOptionModule [ "services" "httpd" httpdName "enableUserDir" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
61 + (mkRemovedOptionModule [ "services" "httpd" httpdName "globalRedirect" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
62 + (mkRemovedOptionModule [ "services" "httpd" httpdName "hostName" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
63 + (mkRemovedOptionModule [ "services" "httpd" httpdName "listen" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
64 + (mkRemovedOptionModule [ "services" "httpd" httpdName "robotsEntries" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
65 + (mkRemovedOptionModule [ "services" "httpd" httpdName "servedDirs" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
66 + (mkRemovedOptionModule [ "services" "httpd" httpdName "servedFiles" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
67 + (mkRemovedOptionModule [ "services" "httpd" httpdName "serverAliases" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
68 + (mkRemovedOptionModule [ "services" "httpd" httpdName "sslServerCert" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
69 + (mkRemovedOptionModule [ "services" "httpd" httpdName "sslServerChain" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
70 + (mkRemovedOptionModule [ "services" "httpd" httpdName "sslServerKey" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
78 + services.httpd."${httpdName}" = {
80 enable = mkEnableOption "the Apache HTTP Server";
83 Using config.services.httpd.virtualHosts."${name}".servedFiles is deprecated and will become unsupported in a future release. Your configuration will continue to work as is but please migrate your configuration to config.services.httpd.virtualHosts."${name}".locations before the 20.09 release of NixOS.
84 '') (filterAttrs (name: hostOpts: hostOpts.servedFiles != []) cfg.virtualHosts);
86 - users.users = optionalAttrs (cfg.user == "wwwrun") {
87 + users.users = optionalAttrs (withUsers && cfg.user == "wwwrun") {
90 description = "Apache httpd user";
95 - users.groups = optionalAttrs (cfg.group == "wwwrun") {
96 + users.groups = optionalAttrs (withUsers && cfg.group == "wwwrun") {
97 wwwrun.gid = config.ids.gids.wwwrun;
101 environment.systemPackages = [ pkg ];
103 # required for "apachectl configtest"
104 - environment.etc."httpd/httpd.conf".source = httpdConf;
105 + environment.etc."httpd/httpd_${httpdName}.conf".source = httpdConf;
107 - services.httpd.phpOptions =
108 + services.httpd."${httpdName}" = { phpOptions =
110 ; Needed for PHP's mail() function.
111 sendmail_path = sendmail -t -i
113 date.timezone = "${config.time.timeZone}"
116 - services.httpd.extraModules = mkBefore [
117 + extraModules = mkBefore [
118 # HTTP authentication mechanisms: basic and digest.
119 "auth_basic" "auth_digest"
121 @@ -682,17 +678,18 @@
122 # For compatibility with old configurations, the new module mod_access_compat is provided.
127 systemd.tmpfiles.rules =
129 - svc = config.systemd.services.httpd.serviceConfig;
130 + svc = config.systemd.services."httpd${httpdName}".serviceConfig;
133 "d '${cfg.logDir}' 0700 ${svc.User} ${svc.Group}"
134 "Z '${cfg.logDir}' - ${svc.User} ${svc.Group}"
137 - systemd.services.httpd =
138 + systemd.services."httpd${httpdName}" =
140 vhostsACME = filter (hostOpts: hostOpts.enableACME) vhosts;
143 PIDFile = "${runtimeDir}/httpd.pid";
146 - RuntimeDirectory = "httpd httpd/runtime";
147 + RuntimeDirectory = "httpd_${httpdName} httpd_${httpdName}/runtime";
148 RuntimeDirectoryMode = "0750";