-
Notifications
You must be signed in to change notification settings - Fork 0
/
acme.nix
41 lines (39 loc) · 1.11 KB
/
acme.nix
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
{ config, lib, pkgs, ... }:
let
inherit (lib) types mkEnableOption mkIf mkOption;
cfg = config.modules.acme;
serverName = config.networking.fqdn;
in {
options.modules.acme = {
enable = mkEnableOption "acme";
email = mkOption {
type = types.nullOr types.str;
default = null;
description =
"Contact email address for the CA (letsencrypt) to be able to reach you.";
};
dnsProvider = mkOption {
type = types.nullOr types.str;
default = null;
description = "Dns provider to use for the ACME stuff";
};
credentialsFile = mkOption {
type = types.nullOr types.path;
default = null;
description = "Credentials to store API tokens of your DNS provider";
};
};
config = mkIf cfg.enable {
# Retrieve TLS certificates from letsencrypt
security.acme.acceptTerms = true;
security.acme.email = cfg.email;
security.acme.certs = {
"${serverName}" = {
group = "caddy";
dnsProvider = cfg.dnsProvider;
reloadServices = [ "caddy.service" ];
credentialsFile = cfg.credentialsFile;
};
};
};
}