unifi: switch to nixos module
All checks were successful
flake / flake (push) Successful in 1m24s

This commit is contained in:
Jake Hillion 2024-07-19 13:50:22 +01:00
parent 0edb8394c8
commit 1052379119

View File

@ -10,20 +10,14 @@ in
dataDir = lib.mkOption { dataDir = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "/var/lib/unifi"; default = "/var/lib/unifi";
readOnly = true; # NixOS module only supports this directory
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.users.unifi = { # Fix dynamically allocated user and group ids
uid = config.ids.uids.unifi; users.users.unifi.uid = config.ids.uids.unifi;
isSystemUser = true; users.groups.unifi.gid = config.ids.gids.unifi;
group = "unifi";
description = "UniFi controller daemon user";
home = "${cfg.dataDir}";
};
users.groups.unifi = {
gid = config.ids.gids.unifi;
};
services.caddy = { services.caddy = {
enable = true; enable = true;
@ -38,21 +32,9 @@ in
}; };
}; };
virtualisation.oci-containers.containers = { services.unifi = {
"unifi" = { enable = true;
image = "lscr.io/linuxserver/unifi-controller:8.0.24-ls221"; unifiPackage = pkgs.unifi8;
environment = {
PUID = toString config.ids.uids.unifi;
PGID = toString config.ids.gids.unifi;
TZ = "Etc/UTC";
};
volumes = [ "${cfg.dataDir}:/config" ];
ports = [
"8080:8080"
"8443:8443"
"3478:3478/udp"
];
};
}; };
}; };
} }