1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

fix: need to split wildcard definitions because the nginx module would cause infinite recursion otherwise

This commit is contained in:
oddlama 2024-04-09 20:38:40 +02:00
parent c410a6b703
commit 76d6a094dc
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
8 changed files with 16 additions and 19 deletions

View file

@ -17,7 +17,7 @@ including my homelab, external servers and my development machines.
🖥️ | Server | sire | Threadripper 1950X | Home media server and data storage. Runs all services as microvms. 🖥️ | Server | sire | Threadripper 1950X | Home media server and data storage. Runs all services as microvms.
🥔 | Server | zackbiene | ODROID N2+ | ARM SBC for home automation, isolating the sketchy stuff from my main network 🥔 | Server | zackbiene | ODROID N2+ | ARM SBC for home automation, isolating the sketchy stuff from my main network
☁️ | VPS | sentinel | Hetzner Cloud server | Proxies and protects my local services ☁️ | VPS | sentinel | Hetzner Cloud server | Proxies and protects my local services
☁️ | VPS | envoy | Hetzner Cloud server | Mailserver (WIP, still on gentoo) ☁️ | VPS | envoy | Hetzner Cloud server | Mailserver
## Overview ## Overview

View file

@ -24,6 +24,6 @@ in {
dnsPropagationCheck = true; dnsPropagationCheck = true;
reloadServices = ["nginx"]; reloadServices = ["nginx"];
}; };
inherit (acme) certs; inherit (acme) certs wildcardDomains;
}; };
} }

View file

@ -14,7 +14,6 @@
boot.mode = "bios"; boot.mode = "bios";
users.groups.acme.members = ["nginx"]; users.groups.acme.members = ["nginx"];
wireguard.proxy-sentinel.firewallRuleForAll.allowedTCPPorts = [80 443];
services.nginx.enable = true; services.nginx.enable = true;
services.nginx.recommendedSetup = true; services.nginx.recommendedSetup = true;

Binary file not shown.

View file

@ -24,6 +24,6 @@ in {
dnsPropagationCheck = true; dnsPropagationCheck = true;
reloadServices = ["nginx"]; reloadServices = ["nginx"];
}; };
inherit (acme) certs; inherit (acme) certs wildcardDomains;
}; };
} }

Binary file not shown.

View file

@ -6,9 +6,8 @@
inherit inherit
(lib) (lib)
assertMsg assertMsg
attrNames
filter filter
filterAttrs genAttrs
hasInfix hasInfix
head head
mkIf mkIf
@ -16,19 +15,14 @@
removeSuffix removeSuffix
types types
; ;
wildcardDomains = attrNames (filterAttrs (_: v: v.wildcard) config.security.acme.certs);
in { in {
options.security.acme.certs = mkOption { options.security.acme.wildcardDomains = mkOption {
type = types.attrsOf (types.submodule (submod: { type = types.listOf types.str;
options.wildcard = mkOption { default = [];
default = false; description = ''
type = types.bool; List of domains to which a wilcard certificate exists under the same name in `certs`.
description = "If set to true, this will automatically append `*.<domain>` to `extraDomainNames`."; All of these certs will automatically have `*.<domain>` appended to `extraDomainNames`.
}; '';
config.extraDomainNames = mkIf submod.config.wildcard ["*.${submod.config._module.args.name}"];
}));
}; };
options.services.nginx.virtualHosts = mkOption { options.services.nginx.virtualHosts = mkOption {
@ -45,7 +39,7 @@ in {
matchingCerts = matchingCerts =
filter filter
(x: !hasInfix "." (removeSuffix ".${x}" domain)) (x: !hasInfix "." (removeSuffix ".${x}" domain))
wildcardDomains; config.security.acme.wildcardDomains;
in in
mkIf submod.config.useACMEWildcardHost { mkIf submod.config.useACMEWildcardHost {
useACMEHost = assert assertMsg (matchingCerts != []) "No wildcard certificate was defined that matches ${domain}"; useACMEHost = assert assertMsg (matchingCerts != []) "No wildcard certificate was defined that matches ${domain}";
@ -53,4 +47,8 @@ in {
}; };
})); }));
}; };
config.security.acme.certs = genAttrs config.security.acme.wildcardDomains (domain: {
extraDomainNames = ["*.${domain}"];
});
} }

Binary file not shown.