dotfiles/modules/nixos/services/prompter/default.nix
2025-07-27 18:11:02 -05:00

46 lines
1,007 B
Nix

{ config, flake, ... }:
let
inherit (flake.config.services.instances)
prompter
;
service = prompter;
host = prompter.domains.url0;
in
{
services = {
caddy = {
virtualHosts = {
"${host}" = {
extraConfig = ''
basicauth {
import ${config.sops.secrets."caddy/${service.name}-auth".path}
}
root * ${service.paths.path0}
file_server
encode gzip
try_files {path} /index.html
tls ${service.ssl.cert} ${service.ssl.key}
'';
};
};
};
};
sops =
let
sopsPath = secret: {
path = "${service.sops.path0}/${service.name}-${secret}.env";
owner = "caddy";
mode = "0400";
};
in
{
secrets = {
"caddy/${service.name}-auth" = sopsPath "auth";
};
};
systemd.tmpfiles.rules = [
"Z ${service.paths.path0} 755 caddy caddy -"
"Z ${service.sops.path0} 755 caddy caddy -"
];
}