Skip to content

Commit 7c8b3c8

Browse files
committed
nixos/h2o: rename certNames → acmeCertNames
We are in agreement ðis improves the naming clarity
1 parent 0c67557 commit 7c8b3c8

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

nixos/modules/services/web-servers/h2o/default.nix

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let
5252

5353
# Attrset with the ACME certificate names split by whether or not they depend
5454
# on H2O serving challenges.
55-
certNames =
55+
acmeCertNames =
5656
let
5757
partition =
5858
acc: vhostSettings:
@@ -67,14 +67,14 @@ let
6767
else
6868
acc;
6969

70-
certNames' = lib.lists.foldl partition {
70+
certNames = lib.lists.foldl partition {
7171
dependent = [ ];
7272
independent = [ ];
7373
} acmeEnabledHostsConfigs;
7474
in
75-
certNames'
75+
certNames
7676
// {
77-
all = certNames'.dependent ++ certNames'.independent;
77+
all = certNames.dependent ++ certNames.independent;
7878
};
7979

8080
mozTLSRecs =
@@ -115,7 +115,7 @@ let
115115

116116
names = getNames name value;
117117

118-
acmeSettings = lib.optionalAttrs (builtins.elem names.cert certNames.dependent) (
118+
acmeSettings = lib.optionalAttrs (builtins.elem names.cert acmeCertNames.dependent) (
119119
let
120120
acmePort = 80;
121121
acmeChallengePath = "/.well-known/acme-challenge";
@@ -171,7 +171,7 @@ let
171171
# stapling.
172172
#
173173
# 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) {
175175
ocsp-update-interval = 0;
176176
}
177177
# Mozilla’s ssl-config-generator is at present still
@@ -229,7 +229,7 @@ let
229229
let
230230
identity =
231231
value.tls.identity
232-
++ lib.optional (builtins.elem names.cert certNames.all) {
232+
++ lib.optional (builtins.elem names.cert acmeCertNames.all) {
233233
key-file = "${certs.${names.cert}.directory}/key.pem";
234234
certificate-file = "${certs.${names.cert}.directory}/fullchain.pem";
235235
};
@@ -411,9 +411,9 @@ in
411411
groups = config.users.groups;
412412
services = [
413413
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;
415415
}
416-
) certNames.all;
416+
) acmeCertNames.all;
417417

418418
users = {
419419
users.${cfg.user} =
@@ -429,13 +429,13 @@ in
429429
systemd.services.h2o = {
430430
description = "H2O HTTP server";
431431
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);
433433
# 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;
435435
after =
436436
[ "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
439439

440440
serviceConfig = {
441441
ExecStart = "${h2oExe} --mode 'master'";
@@ -488,15 +488,17 @@ in
488488
# of certs end-to-end.
489489
systemd.services.h2o-config-reload =
490490
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;
493493
in
494-
mkIf (certNames.all != [ ]) {
494+
mkIf (acmeCertNames.all != [ ]) {
495495
wantedBy = tlsServices ++ [ "multi-user.target" ];
496496
before = tlsTargets;
497497
after = tlsServices;
498498
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;
500502
# Disable rate limiting for this since it may be triggered quickly
501503
# a bunch of times if a lot of certificates are renewed in quick
502504
# succession. The reload itself is cheap, so even doing a lot of them

0 commit comments

Comments
 (0)