git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/httpd: provide a stable path stable path to the configuration file for reloads
commitf20aa073e16dc07cfd4ce9a7e0d39445282c575d authorAaron Andersen <aaron@fosslib.net> dateTue 11 May 2021, 19:51 (6 years ago) parent774550b
1 file changed+9−7
nixos/modules/services/web-servers/apache-httpd/default.nix+9−7
nixos/modules/services/web-servers/apache-httpd/default.nix+9−7
@@ -15,11 +15,9 @@ let
1515 apachectl = pkgs.runCommand "apachectl" { meta.priority = -1; } ''
1616 mkdir -p $out/bin
1717 cp ${pkg}/bin/apachectl $out/bin/apachectl
18− sed -i $out/bin/apachectl -e 's|$HTTPD -t|$HTTPD -t -f ${httpdConf}|'
18+ sed -i $out/bin/apachectl -e 's|$HTTPD -t|$HTTPD -t -f /etc/httpd/httpd.conf|'
1919 '';
2020
21− httpdConf = cfg.configFile;
22−
2321 php = cfg.phpPackage.override { apacheHttpd = pkg; };
2422
2523 phpModuleName = let
@@ -682,6 +680,8 @@ in
682680 }) (filter (hostOpts: hostOpts.useACMEHost == null) acmeEnabledVhosts);
683681 in listToAttrs acmePairs;
684682
683+ # httpd requires a stable path to the configuration file for reloads
684+ environment.etc."httpd/httpd.conf".source = cfg.configFile;
685685 environment.systemPackages = [
686686 apachectl
687687 pkg
@@ -753,6 +753,7 @@ in
753753 wants = concatLists (map (certName: [ "acme-finished-${certName}.target" ]) dependentCertNames);
754754 after = [ "network.target" ] ++ map (certName: "acme-selfsigned-${certName}.service") dependentCertNames;
755755 before = map (certName: "acme-${certName}.service") dependentCertNames;
756+ restartTriggers = [ cfg.configFile ];
756757
757758 path = [ pkg pkgs.coreutils pkgs.gnugrep ];
758759
@@ -771,9 +772,9 @@ in
771772 '';
772773
773774 serviceConfig = {
774− ExecStart = "@${pkg}/bin/httpd httpd -f ${httpdConf}";
775− ExecStop = "${pkg}/bin/httpd -f ${httpdConf} -k graceful-stop";
776− ExecReload = "${pkg}/bin/httpd -f ${httpdConf} -k graceful";
775+ ExecStart = "@${pkg}/bin/httpd httpd -f /etc/httpd/httpd.conf";
776+ ExecStop = "${pkg}/bin/httpd -f /etc/httpd/httpd.conf -k graceful-stop";
777+ ExecReload = "${pkg}/bin/httpd -f /etc/httpd/httpd.conf -k graceful";
777778 User = cfg.user;
778779 Group = cfg.group;
779780 Type = "forking";
@@ -800,6 +801,7 @@ in
800801 # certs are updated _after_ config has been reloaded.
801802 before = sslTargets;
802803 after = sslServices;
804+ restartTriggers = [ cfg.configFile ];
803805 # Block reloading if not all certs exist yet.
804806 # Happens when config changes add new vhosts/certs.
805807 unitConfig.ConditionPathExists = map (certName: certs.${certName}.directory + "/fullchain.pem") dependentCertNames;
@@ -807,7 +809,7 @@ in
807809 Type = "oneshot";
808810 TimeoutSec = 60;
809811 ExecCondition = "/run/current-system/systemd/bin/systemctl -q is-active httpd.service";
810− ExecStartPre = "${pkg}/bin/httpd -f ${httpdConf} -t";
812+ ExecStartPre = "${pkg}/bin/httpd -f /etc/httpd/httpd.conf -t";
811813 ExecStart = "/run/current-system/systemd/bin/systemctl reload httpd.service";
812814 };
813815 };