WIP: Authentik

This commit is contained in:
pazpi 2025-01-12 22:27:37 +01:00
parent 79bfb5e7e3
commit a1bc147b90
9 changed files with 440 additions and 17 deletions

View file

@ -0,0 +1,115 @@
{
lib,
config,
pkgs,
...
}:
let
cfg = config.my.services.authentik;
in
{
options.my.services.authentik = {
enable = lib.mkEnableOption "Enable Authentik module";
envFile = lib.mkOption {
default = "";
type = lib.types.str;
description = ''
The path to the env file
'';
};
email = {
host = lib.mkOption {
type = lib.types.str;
description = "SMTP server host for Authentik.";
default = "smtp.example.com";
};
port = lib.mkOption {
type = lib.types.int;
description = "SMTP server port for Authentik.";
default = 587;
};
username = lib.mkOption {
type = lib.types.str;
description = "SMTP username for Authentik.";
default = "authentik@example.com";
};
use_tls = lib.mkOption {
type = lib.types.bool;
description = "Use TLS for SMTP connection.";
default = true;
};
use_ssl = lib.mkOption {
type = lib.types.bool;
description = "Use SSL for SMTP connection.";
default = false;
};
from = lib.mkOption {
type = lib.types.str;
description = "Email address to use in the From field.";
default = "authentik@example.com";
};
};
proxy = {
enable = lib.mkEnableOption "Set the proxy entry for this service";
domain = lib.mkOption {
default = "example.com";
type = lib.types.str;
description = ''
The domain where Caddy is reachable
'';
};
subdomain = lib.mkOption {
default = "auth";
type = lib.types.str;
description = ''
The subdomain where the service is reachable
'';
};
host = lib.mkOption {
default = "localhost";
type = lib.types.str;
description = ''
host name where the service is running
'';
};
};
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
services.authentik = {
enable = true;
environmentFile = cfg.envFile;
settings = {
email = cfg.email;
disable_startup_analytics = true;
avatars = "initials";
};
nginx = {
enable = true;
enableACME = false;
host = "${cfg.proxy.subdomain}.${cfg.proxy.domain}";
};
};
})
(lib.mkIf cfg.proxy.enable {
services.caddy = with cfg.proxy; {
virtualHosts."${subdomain}.${domain}".extraConfig = ''
reverse_proxy http://localhost:9000
import cloudflare_${domain}
'';
};
})
];
}

View file

@ -1,5 +1,6 @@
{
imports = [
./authentik.nix
./dashy.nix
./media-mgr.nix
./nextcloud.nix