mailsystem: Add nginx configuration to retrieve letsencrypt certificate
This commit is contained in:
parent
77e4cac42d
commit
3943ec3356
2 changed files with 41 additions and 0 deletions
21
mailsystem/default.nix
Normal file
21
mailsystem/default.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{lib, ...}: {
|
||||
options.mailsystem = {
|
||||
enable = lib.mkEnableOption "nixos-mailsystem";
|
||||
|
||||
openFirewall = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Automatically open ports in the firewall.";
|
||||
};
|
||||
|
||||
fqdn = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "mail.example.com";
|
||||
description = "Fully qualified domain name of the mail server.";
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
./nginx.nix
|
||||
];
|
||||
}
|
||||
20
mailsystem/nginx.nix
Normal file
20
mailsystem/nginx.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.mailsystem;
|
||||
in {
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."${cfg.fqdn}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [80 443];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue