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