2024-05-20 20:52:57 -04:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
|
|
|
let
|
2024-06-24 11:38:28 -04:00
|
|
|
cfg = config.aux.system.services.acme;
|
2024-05-20 20:52:57 -04:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2024-06-24 11:38:28 -04:00
|
|
|
aux.system.services.acme = {
|
2024-09-08 11:58:56 -04:00
|
|
|
enable = lib.mkEnableOption "Enable the ACME client (for Let's Encrypt TLS certificates).";
|
2024-05-20 20:52:57 -04:00
|
|
|
certs = lib.mkOption {
|
|
|
|
default = { };
|
|
|
|
type = lib.types.attrs;
|
|
|
|
description = "Cert configurations for ACME.";
|
|
|
|
};
|
|
|
|
defaultEmail = lib.mkOption {
|
|
|
|
default = "";
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Default admin email to use for problems.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
|
|
|
defaults.email = cfg.defaultEmail;
|
|
|
|
certs = cfg.certs;
|
|
|
|
};
|
|
|
|
|
|
|
|
# /var/lib/acme/.challenges must be writable by the ACME user
|
|
|
|
# and readable by the Nginx user. The easiest way to achieve
|
|
|
|
# this is to add the Nginx user to the ACME group.
|
2024-06-24 11:38:28 -04:00
|
|
|
users.users.nginx.extraGroups = lib.mkIf config.aux.system.services.nginx.enable [ "acme" ];
|
2024-05-20 20:52:57 -04:00
|
|
|
};
|
|
|
|
}
|