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];};
};
};
}
+1 -5
View File
@@ -5,7 +5,6 @@
...
}: let
cfg = config.homelab.ddns;
token = config.sops.secrets."cloudflare/api_token".path;
sec = config.sops.secrets;
in {
options.homelab.ddns = {
@@ -15,7 +14,7 @@ in {
config = lib.mkIf cfg.enable {
services.cloudflare-ddns = {
enable = true;
credentialsFile = token;
credentialsFile = sec."cloudflare/api_token".path;
domains = [
# recoil.pro
"recoil.pro"
@@ -31,12 +30,9 @@ in {
"*.blakedheld.xyz"
"git.blakedheld.xyz"
"up.blakedheld.xyz"
];
};
# network config
# declare authkey secrets
sops.secrets = {
"cloudflare/api_token" = {
+7 -4
View File
@@ -6,8 +6,6 @@
}: let
service = "dnsmasq";
cfg = config.homelab.${service};
sec = config.sops.secrets;
homelab = config.homelab;
in {
options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}";
@@ -16,6 +14,11 @@ in {
default = 53;
description = "set port for ${service} (default: ${toString cfg.port}";
};
upstream = lib.mkOption {
type = lib.types.str;
default = "10.10.0.1";
description = "set upstream dns server for ${service} (default: $cfg.upstream}";
};
};
config = lib.mkIf cfg.enable {
@@ -25,7 +28,7 @@ in {
alwaysKeepRunning = true;
settings = {
no-resolv = true;
listen-address = "10.10.0.11"; # your LAN IP
listen-address = config.homelab.host_ip; # your LAN IP
#interface = "enp89s0";
bind-interfaces = true;
# address = [
@@ -35,7 +38,7 @@ in {
# ];
server = [
# upstream dns
"10.10.0.1"
cfg.upstream
];
};
};
@@ -5,7 +5,7 @@
...
}: let
cfg = config.homelab.tailscale;
authkey_file = config.sops.secrets."tailscale_authkey".path;
sec = config.sops.secrets;
in {
options.homelab.tailscale = {
enable = lib.mkEnableOption "enables tailscale";
@@ -16,7 +16,7 @@ in {
enable = true;
openFirewall = true;
useRoutingFeatures = "both";
authKeyFile = authkey_file;
authKeyFile = sec."tailscale_authkey".path;;
extraSetFlags = [
"--advertise-routes=${config.homelab.host_ip}/32" # advertise self
"--accept-routes=false" # true is equilivant to useRoutingFeatures = "client" (breaks shit)