1
0
mirror of https://github.com/tboerger/nixos-config synced 2024-11-26 07:43:45 +01:00
github.com-tboerger-nixos-c.../shared/services/auth.nix

158 lines
3.2 KiB
Nix
Raw Normal View History

2022-10-25 09:53:40 +02:00
{ pkgs, lib, config, options, fetchurl, ... }:
with lib;
let
cfg = config.personal.services.auth;
2024-07-17 16:05:33 +02:00
hostAddress = "192.168.100.40";
containerAddress = "192.168.100.41";
2022-10-25 09:53:40 +02:00
in
{
options = {
personal = {
services = {
auth = {
enable = mkEnableOption "Auth";
2022-10-25 09:53:40 +02:00
};
};
};
};
config = mkIf cfg.enable {
2024-07-17 16:05:33 +02:00
networking.firewall = {
allowedTCPPorts = [ 636 ];
};
containers = {
auth = {
autoStart = true;
privateNetwork = true;
ephemeral = true;
hostAddress = hostAddress;
localAddress = containerAddress;
2022-10-25 09:53:40 +02:00
2024-07-17 16:05:33 +02:00
forwardPorts = [{
protocol = "tcp";
hostPort = 636;
containerPort = 636;
}];
bindMounts = {
"/var/lib/acme" = {
hostPath = "/var/lib/acme";
isReadOnly = true;
};
"/var/lib/kanidm" = {
hostPath = "/var/lib/kanidm";
isReadOnly = false;
};
};
2024-07-17 16:05:33 +02:00
config = { config, pkgs, ... }: {
system = {
stateVersion = "23.11";
};
2024-07-17 16:05:33 +02:00
systemd = {
tmpfiles = {
rules = [ "d /var/lib/kanidm 0700 kanidm kanidm" ];
};
2024-07-17 16:05:33 +02:00
};
environment = {
systemPackages = with pkgs; [
sqlite
];
};
services = {
resolved = {
enable = true;
};
kanidm = {
enableServer = true;
serverSettings = {
bindaddress = "0.0.0.0:8443";
ldapbindaddress = "0.0.0.0:636";
domain = "auth.boerger.ws";
origin = "https://auth.boerger.ws";
log_level = "info";
tls_key = "/var/lib/acme/boerger.ws/key.pem";
tls_chain = "/var/lib/acme/boerger.ws/fullchain.pem";
};
enableClient = true;
clientSettings = {
uri = "https://auth.boerger.ws";
};
};
};
2024-07-17 16:05:33 +02:00
networking = {
useHostResolvConf = mkForce false;
firewall = {
enable = true;
allowedTCPPorts = [ 636 8443 ];
};
};
ids.uids = {
acme = 400;
};
ids.gids = {
acme = 400;
};
users = {
users = {
acme = {
home = "/var/lib/acme";
group = "acme";
isSystemUser = true;
uid = config.ids.uids.acme;
};
kanidm = {
extraGroups = [
"acme"
];
};
};
};
users.groups = {
acme = {
gid = config.ids.gids.acme;
};
};
};
};
2022-10-25 09:53:40 +02:00
};
personal = {
services = {
acme = {
2022-10-25 09:53:40 +02:00
enable = true;
};
2022-10-25 09:53:40 +02:00
webserver = {
enable = true;
2024-07-17 16:05:33 +02:00
hosts = [
{
domain = "auth.boerger.ws";
proxy = "https://${containerAddress}:8443";
}
];
2022-10-25 09:53:40 +02:00
};
};
};
};
}