|
52 | 52 |
|
53 | 53 | # Attrset with the ACME certificate names split by whether or not they depend |
54 | 54 | # on H2O serving challenges. |
55 | | - certNames = |
| 55 | + acmeCertNames = |
56 | 56 | let |
57 | 57 | partition = |
58 | 58 | acc: vhostSettings: |
|
67 | 67 | else |
68 | 68 | acc; |
69 | 69 |
|
70 | | - certNames' = lib.lists.foldl partition { |
| 70 | + certNames = lib.lists.foldl partition { |
71 | 71 | dependent = [ ]; |
72 | 72 | independent = [ ]; |
73 | 73 | } acmeEnabledHostsConfigs; |
74 | 74 | in |
75 | | - certNames' |
| 75 | + certNames |
76 | 76 | // { |
77 | | - all = certNames'.dependent ++ certNames'.independent; |
| 77 | + all = certNames.dependent ++ certNames.independent; |
78 | 78 | }; |
79 | 79 |
|
80 | 80 | mozTLSRecs = |
|
115 | 115 |
|
116 | 116 | names = getNames name value; |
117 | 117 |
|
118 | | - acmeSettings = lib.optionalAttrs (builtins.elem names.cert certNames.dependent) ( |
| 118 | + acmeSettings = lib.optionalAttrs (builtins.elem names.cert acmeCertNames.dependent) ( |
119 | 119 | let |
120 | 120 | acmePort = 80; |
121 | 121 | acmeChallengePath = "/.well-known/acme-challenge"; |
|
171 | 171 | # stapling. |
172 | 172 | # |
173 | 173 | # See: https://letsencrypt.org/2024/12/05/ending-ocsp/ |
174 | | - lib.optionalAttrs (builtins.elem names.cert certNames.all) { |
| 174 | + lib.optionalAttrs (builtins.elem names.cert acmeCertNames.all) { |
175 | 175 | ocsp-update-interval = 0; |
176 | 176 | } |
177 | 177 | # Mozilla’s ssl-config-generator is at present still |
|
229 | 229 | let |
230 | 230 | identity = |
231 | 231 | value.tls.identity |
232 | | - ++ lib.optional (builtins.elem names.cert certNames.all) { |
| 232 | + ++ lib.optional (builtins.elem names.cert acmeCertNames.all) { |
233 | 233 | key-file = "${certs.${names.cert}.directory}/key.pem"; |
234 | 234 | certificate-file = "${certs.${names.cert}.directory}/fullchain.pem"; |
235 | 235 | }; |
|
411 | 411 | groups = config.users.groups; |
412 | 412 | services = [ |
413 | 413 | config.systemd.services.h2o |
414 | | - ] ++ lib.optional (certNames.all != [ ]) config.systemd.services.h2o-config-reload; |
| 414 | + ] ++ lib.optional (acmeCertNames.all != [ ]) config.systemd.services.h2o-config-reload; |
415 | 415 | } |
416 | | - ) certNames.all; |
| 416 | + ) acmeCertNames.all; |
417 | 417 |
|
418 | 418 | users = { |
419 | 419 | users.${cfg.user} = |
|
429 | 429 | systemd.services.h2o = { |
430 | 430 | description = "H2O HTTP server"; |
431 | 431 | wantedBy = [ "multi-user.target" ]; |
432 | | - wants = lib.concatLists (map (certName: [ "acme-finished-${certName}.target" ]) certNames.all); |
| 432 | + wants = lib.concatLists (map (certName: [ "acme-finished-${certName}.target" ]) acmeCertNames.all); |
433 | 433 | # Since H2O will be hosting the challenges, H2O must be started |
434 | | - before = builtins.map (certName: "acme-${certName}.service") certNames.dependent; |
| 434 | + before = builtins.map (certName: "acme-${certName}.service") acmeCertNames.dependent; |
435 | 435 | after = |
436 | 436 | [ "network.target" ] |
437 | | - ++ builtins.map (certName: "acme-selfsigned-${certName}.service") certNames.all |
438 | | - ++ builtins.map (certName: "acme-${certName}.service") certNames.independent; # avoid loading self-signed key w/ real cert, or vice-versa |
| 437 | + ++ builtins.map (certName: "acme-selfsigned-${certName}.service") acmeCertNames.all |
| 438 | + ++ builtins.map (certName: "acme-${certName}.service") acmeCertNames.independent; # avoid loading self-signed key w/ real cert, or vice-versa |
439 | 439 |
|
440 | 440 | serviceConfig = { |
441 | 441 | ExecStart = "${h2oExe} --mode 'master'"; |
|
488 | 488 | # of certs end-to-end. |
489 | 489 | systemd.services.h2o-config-reload = |
490 | 490 | let |
491 | | - tlsTargets = map (certName: "acme-${certName}.target") certNames.all; |
492 | | - tlsServices = map (certName: "acme-${certName}.service") certNames.all; |
| 491 | + tlsTargets = map (certName: "acme-${certName}.target") acmeCertNames.all; |
| 492 | + tlsServices = map (certName: "acme-${certName}.service") acmeCertNames.all; |
493 | 493 | in |
494 | | - mkIf (certNames.all != [ ]) { |
| 494 | + mkIf (acmeCertNames.all != [ ]) { |
495 | 495 | wantedBy = tlsServices ++ [ "multi-user.target" ]; |
496 | 496 | before = tlsTargets; |
497 | 497 | after = tlsServices; |
498 | 498 | unitConfig = { |
499 | | - ConditionPathExists = map (certName: "${certs.${certName}.directory}/fullchain.pem") certNames.all; |
| 499 | + ConditionPathExists = map ( |
| 500 | + certName: "${certs.${certName}.directory}/fullchain.pem" |
| 501 | + ) acmeCertNames.all; |
500 | 502 | # Disable rate limiting for this since it may be triggered quickly |
501 | 503 | # a bunch of times if a lot of certificates are renewed in quick |
502 | 504 | # succession. The reload itself is cheap, so even doing a lot of them |
|
0 commit comments