about summary refs log tree commit diff
path: root/profiles/unifi.nix
blob: 23cb1b4e43f9acafe687d7870b62c132e0931368 (plain) (blame)
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
{ config, lib, pkgs, ... }:

let
  secrets = config.age.secrets;
  vhostName = "unifi.${config.homelab.domain}";
in
{
  # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/unifi.nix
  services.unifi = {
    enable = true;
    openFirewall = true;
    unifiPackage = pkgs.unifi7;
    mongodbPackage = pkgs.mongodb-4_2;
  };

  services.nginx.virtualHosts."${vhostName}" = {
    forceSSL = true;
    useACMEHost = config.homelab.domain;
    listen = [
      {
        addr = "192.168.6.40";
        port = 443;
        ssl = true;
      }
      {
        addr = "192.168.6.40";
        port = 80;
        ssl = false;
      }
    ];
    locations."/" = {
      proxyPass = "https://127.0.0.1:8443";
      proxyWebsockets = true;
    };
  };

  my.services.backup = { paths = [ "/var/lib/unifi/data/backup" ]; };
}