Merge pull request #122658 from aanderse/httpd-reload

nixos/httpd: provide a stable path stable path to the configuration f…

authored by Aaron Andersen and committed by GitHub fc63be7a d9868214

+9 -7
+9 -7
nixos/modules/services/web-servers/apache-httpd/default.nix
··· 15 15 apachectl = pkgs.runCommand "apachectl" { meta.priority = -1; } '' 16 16 mkdir -p $out/bin 17 17 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|' 19 19 ''; 20 - 21 - httpdConf = cfg.configFile; 22 20 23 21 php = cfg.phpPackage.override { apacheHttpd = pkg; }; 24 22 ··· 682 680 }) (filter (hostOpts: hostOpts.useACMEHost == null) acmeEnabledVhosts); 683 681 in listToAttrs acmePairs; 684 682 683 + # httpd requires a stable path to the configuration file for reloads 684 + environment.etc."httpd/httpd.conf".source = cfg.configFile; 685 685 environment.systemPackages = [ 686 686 apachectl 687 687 pkg ··· 753 753 wants = concatLists (map (certName: [ "acme-finished-${certName}.target" ]) dependentCertNames); 754 754 after = [ "network.target" ] ++ map (certName: "acme-selfsigned-${certName}.service") dependentCertNames; 755 755 before = map (certName: "acme-${certName}.service") dependentCertNames; 756 + restartTriggers = [ cfg.configFile ]; 756 757 757 758 path = [ pkg pkgs.coreutils pkgs.gnugrep ]; 758 759 ··· 771 772 ''; 772 773 773 774 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"; 777 778 User = cfg.user; 778 779 Group = cfg.group; 779 780 Type = "forking"; ··· 800 801 # certs are updated _after_ config has been reloaded. 801 802 before = sslTargets; 802 803 after = sslServices; 804 + restartTriggers = [ cfg.configFile ]; 803 805 # Block reloading if not all certs exist yet. 804 806 # Happens when config changes add new vhosts/certs. 805 807 unitConfig.ConditionPathExists = map (certName: certs.${certName}.directory + "/fullchain.pem") dependentCertNames; ··· 807 809 Type = "oneshot"; 808 810 TimeoutSec = 60; 809 811 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"; 811 813 ExecStart = "/run/current-system/systemd/bin/systemctl reload httpd.service"; 812 814 }; 813 815 };