file cleanup, conditional motd

This commit is contained in:
2026-06-14 08:35:44 -05:00
parent fcb8961c69
commit 11d3fcd8ec
27 changed files with 407 additions and 409 deletions
+36 -31
View File
@@ -1,12 +1,14 @@
{ pkgs, config, lib, ... }:
let
{
pkgs,
config,
lib,
...
}: let
service = "caddy";
cfg = config.homelab.${service};
sec = config.sops.secrets;
homelab = config.homelab;
in
{
in {
options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}";
@@ -28,12 +30,14 @@ in
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
default =
if cfg.enable
then service
else null;
};
};
config = lib.mkIf cfg.enable {
# declare ${service} group
users.groups.${service} = {};
@@ -57,13 +61,14 @@ in
globalConfig = ''
auto_https ignore_loaded_certs
'';
# static page for hosting key files
virtualHosts."keys.${homelab.base_domain}" = {
serverAliases = [ "keys.${homelab.public_domain}" ];
serverAliases = ["keys.${homelab.public_domain}"];
extraConfig = ''
tls internal
root /var/www/keys
file_server browse
tls internal
root /var/www/keys
file_server browse
'';
};
};
@@ -80,7 +85,7 @@ in
};
# open firewall
networking.firewall.allowedTCPPorts = [ 80 443 ];
networking.firewall.allowedTCPPorts = [80 443];
sops.secrets = {
"ssl_blakedheld_crt" = {
@@ -104,26 +109,26 @@ in
path = "/var/www/keys/caddy_root.crt";
};
};
environment.etc."caddy/browse.html".text = ''
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{html .Name}}</title>
<style>
footer { display: none !important; }
</style>
</head>
<body>
{{template "listing" .}}
</body>
</html>
'';
environment.etc."caddy/browse.html".text = ''
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{html .Name}}</title>
<style>
footer { display: none !important; }
</style>
</head>
<body>
{{template "listing" .}}
</body>
</html>
'';
# add to backups
homelab.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; };
homelab.backups.baks = {
${service} = {paths = [cfg.data_dir];};
};
};
}