blob: b3ebb26f5314019cfce1d828456405a3d16242fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
{ config, lib, ... }:
with lib;
let
cfg = config.modules.services.acme;
in
{
options.modules.services.acme = {
enable = mkEnableOption "ACME certificate manager";
email = mkOption {
type = types.str;
description = mdDoc ''
The postmaster email address to use.
'';
};
certs = mkOption {
type = types.attrsOf
(types.submodule {
options = {
domain = mkOption {
type = types.nullOr types.str;
default = null;
};
subDomains = mkOption { type = types.listOf types.str; };
};
});
};
secrets.acme-credentials = mkOption { type = types.str; description = "path to the acme environment file"; };
};
config = mkIf cfg.enable {
security.acme = {
acceptTerms = true;
defaults.email = cfg.email;
certs = mapAttrs
(name: { domain, subDomains }: {
extraDomainNames = lists.forEach subDomains (elem: elem + ".${name}");
} // {
dnsProvider = "cloudflare";
dnsPropagationCheck = true;
credentialsFile = cfg.secrets.acme-credentials;
} // optionalAttrs (domain != null) {
domain = domain;
})
cfg.certs;
};
modules.persistence.directories = [
"/var/lib/acme"
];
};
}
|