nixos/modules/services/unifi.nix

42 lines
892 B
Nix
Raw Normal View History

2023-12-08 21:59:29 +00:00
{ config, pkgs, lib, ... }:
let
cfg = config.custom.services.unifi;
in
{
options.custom.services.unifi = {
enable = lib.mkEnableOption "unifi";
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/unifi";
2024-07-19 13:50:22 +01:00
readOnly = true; # NixOS module only supports this directory
2023-12-08 21:59:29 +00:00
};
};
config = lib.mkIf cfg.enable {
2024-07-19 13:50:22 +01:00
# Fix dynamically allocated user and group ids
users.users.unifi.uid = config.ids.uids.unifi;
users.groups.unifi.gid = config.ids.gids.unifi;
2023-12-08 21:59:29 +00:00
services.caddy = {
enable = true;
virtualHosts = {
"unifi.hillion.co.uk".extraConfig = ''
reverse_proxy https://localhost:8443 {
transport http {
tls_insecure_skip_verify
}
}
'';
};
};
2024-07-19 13:50:22 +01:00
services.unifi = {
enable = true;
unifiPackage = pkgs.unifi8;
2023-12-08 21:59:29 +00:00
};
};
}