48 lines
941 B
Nix
48 lines
941 B
Nix
{
|
|
config,
|
|
lib,
|
|
namespace,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
cfg = config.${namespace}.services.authentik;
|
|
in
|
|
{
|
|
imports = [ ./options.nix ];
|
|
|
|
config = mkIf cfg.enable {
|
|
services.authentik = {
|
|
enable = true;
|
|
environmentFile = cfg.environmentFile;
|
|
settings = {
|
|
port = cfg.port;
|
|
};
|
|
};
|
|
|
|
# Open firewall for authentik if enabled
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
allowedTCPPorts = [ cfg.port ];
|
|
allowedUDPPorts = [ cfg.port ];
|
|
};
|
|
|
|
# Ensure PostgreSQL is configured for authentik
|
|
services.postgresql = {
|
|
enable = mkDefault true;
|
|
ensureDatabases = [ "authentik" ];
|
|
ensureUsers = [
|
|
{
|
|
name = "authentik";
|
|
ensureDBOwnership = true;
|
|
}
|
|
];
|
|
};
|
|
|
|
# Ensure Redis is configured for authentik
|
|
services.redis.servers.authentik = {
|
|
enable = mkDefault true;
|
|
port = mkDefault 6379;
|
|
};
|
|
};
|
|
}
|