summaryrefslogtreecommitdiff
path: root/profiles/homeserver/nginx.nix
blob: 22fd74e40abc23c676f4bc1b5758932c0221615f (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
{ lib, ... }: with lib; {
  # apparently you can set defaults on existing modules?
  options.services.nginx.virtualHosts = mkOption {
    type = types.attrsOf (types.submodule ({ name, ... }: {
      config = mkIf (name != "default") {
        forceSSL = mkDefault true;
        sslCertificateKey = "/var/lib/acme/${my.domain}/key.pem";
        sslCertificate = "/var/lib/acme/${my.domain}/fullchain.pem";
      };
    }));
  };
  config = {
    services.nginx = {
      enable = true;
      enableReload = true;
      recommendedTlsSettings = true;
      recommendedProxySettings = true;
      recommendedGzipSettings = true;
      recommendedOptimisation = true;
    };
    systemd.services.nginx.serviceConfig = {
      SupplementaryGroups = [ "acme" ];
    };
    networking.firewall.allowedTCPPorts = [ 80 443 ];
  };
}