FUCK YOU MODULES HOMELAB RULES

This commit is contained in:
2025-10-13 22:18:10 -05:00
parent 6682df4338
commit 962f44f05e
38 changed files with 157 additions and 535 deletions

View File

@@ -14,46 +14,44 @@ in
../../modules/homelab/minecraft_recpro ../../modules/homelab/minecraft_recpro
]; ];
modules = { system = {
system = { ssh.enable = true;
ssh.enable = true; backups.enable = true;
backups.enable = true; backups.repo = "/holocron/backups";
backups.repo = "/holocron/backups"; sops.enable = true;
sops.enable = true; podman.enable = true;
podman.enable = true; syncthing.enable = true;
syncthing.enable = true; tailscale.enable = true;
tailscale.enable = true; nvidia.enable = true;
nvidia.enable = true; };
}; fileshare = {
fileshare = { zfs.enable = true;
zfs.enable = true; smb.enable = true;
smb.enable = true; nfs.enable = true;
nfs.enable = true; };
}; homelab = {
homelab.enable = true; enable = true;
services = { gitea.enable = true;
gitea.enable = true; glance.enable = true;
glance.enable = true; immich.enable = true;
immich.enable = true; hass.enable = true;
hass.enable = true; jellyfin.enable = true;
jellyfin.enable = true; audiobookshelf.enable = true;
audiobookshelf.enable = true; yacreader.enable = true;
yacreader.enable = true; qbittorrent.enable = true;
qbittorrent.enable = true; sonarr.enable = true;
sonarr.enable = true; radarr.enable = true;
radarr.enable = true; bazarr.enable = true;
bazarr.enable = true; prowlarr.enable = true;
prowlarr.enable = true; flaresolverr.enable = true;
flaresolverr.enable = true; zigbee2mqtt.enable = true;
zigbee2mqtt.enable = true; mosquitto.enable = true;
mosquitto.enable = true; caddy.enable = true;
caddy.enable = true; uptime-kuma.enable = true;
uptime-kuma.enable = true; vaultwarden.enable = true;
vaultwarden.enable = true; };
}; gameservers = {
gameservers = { minecraft_recpro.enable = true;
minecraft_recpro.enable = true;
};
}; };
# configure users & groups # configure users & groups
@@ -129,12 +127,6 @@ in
# allow proprietary packages # allow proprietary packages
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
# ld fix
programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
# Add any missing dynamic libraries for unpackaged
# programs here, NOT in environment.systemPackages
];
# enable flakes # enable flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ];

View File

@@ -2,12 +2,12 @@
let let
service = "bazarr"; service = "bazarr";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -80,7 +80,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -88,7 +88,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "flaresolverr"; service = "flaresolverr";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options

View File

@@ -2,12 +2,12 @@
let let
service = "prowlarr"; service = "prowlarr";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -82,7 +82,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -90,7 +90,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "radarr"; service = "radarr";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -85,7 +85,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -93,7 +93,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "sonarr"; service = "sonarr";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -83,7 +83,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -91,7 +91,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "audiobookshelf"; service = "audiobookshelf";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -86,7 +86,7 @@ in
}; };
# add to glance public service # add to glance public service
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://abs.${homelab.public_domain}"; url = "https://abs.${homelab.public_domain}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -94,7 +94,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "caddy"; service = "caddy";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -91,7 +91,7 @@ in
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,10 +2,10 @@
let let
cfg = config.modules.homelab; cfg = config.homelab;
in in
{ {
options.modules.homelab = { options.homelab = {
enable = lib.mkEnableOption "enable homelab services and configuration"; enable = lib.mkEnableOption "enable homelab services and configuration";
media_user = lib.mkOption { media_user = lib.mkOption {
default = "media"; default = "media";

View File

@@ -6,13 +6,13 @@
}: }:
# define nfs exports # define nfs exports
let let
cfg = config.modules.fileshare.nfs; cfg = config.fileshare.nfs;
nfs_exports = '' nfs_exports = ''
/holocron/media *(ro,sync,no_subtree_check) /holocron/media *(ro,sync,no_subtree_check)
''; '';
#/holocron/vault *(rw,sync,no_subtree_check,no_root_squash) #/holocron/vault *(rw,sync,no_subtree_check,no_root_squash)
in { in {
options.modules.fileshare.nfs = { options.fileshare.nfs = {
enable = lib.mkEnableOption "enables nfs"; enable = lib.mkEnableOption "enables nfs";
}; };

View File

@@ -6,7 +6,7 @@
}: }:
# define smb shares # define smb shares
let let
cfg = config.modules.fileshare.smb; cfg = config.fileshare.smb;
smb_shares = { smb_shares = {
vault = { vault = {
path = "/holocron/vault"; path = "/holocron/vault";
@@ -22,7 +22,7 @@ let
}; };
}; };
in { in {
options.modules.fileshare.smb = { options.fileshare.smb = {
enable = lib.mkEnableOption "enables smb"; enable = lib.mkEnableOption "enables smb";
}; };

View File

@@ -4,9 +4,9 @@
lib, lib,
... ...
}: let }: let
cfg = config.modules.fileshare.zfs; cfg = config.fileshare.zfs;
in { in {
options.modules.fileshare.zfs = { options.fileshare.zfs = {
enable = lib.mkEnableOption "enables zfs"; enable = lib.mkEnableOption "enables zfs";
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "gitea"; service = "gitea";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -102,7 +102,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.services = [{ homelab.glance.links.services = [{
title = service; title = service;
url = "https://git.${homelab.public_domain}"; url = "https://git.${homelab.public_domain}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -118,7 +118,7 @@ in
}; };
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -12,7 +12,7 @@
| <8yy> | | <8yy> |
V V V V
# add to glance # add to glance
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -23,15 +23,15 @@
let let
service = "glance"; service = "glance";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
uptimekuma_url = "localhost:7901"; uptimekuma_url = "localhost:7901";
uptimekuma_page = "glance"; uptimekuma_page = "glance";
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -288,14 +288,14 @@ in
}; };
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { ${service} = {
paths = [ cfg.data_dir ]; paths = [ cfg.data_dir ];
}; };
}; };
# add to udr to glance # add to udr to glance
modules.services.glance.links.system = [{ homelab.glance.links.system = [{
title = "bebe"; title = "bebe";
url = "https://bebe.lan"; url = "https://bebe.lan";
error-url = "https://10.10.0.1"; error-url = "https://10.10.0.1";

View File

@@ -3,12 +3,12 @@
let let
nixservice = "home-assistant"; nixservice = "home-assistant";
service = "hass"; service = "hass";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -97,7 +97,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.services = [{ homelab.glance.links.services = [{
title = "home assistant"; title = "home assistant";
url = "https://hass.${homelab.public_domain}"; url = "https://hass.${homelab.public_domain}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -105,7 +105,7 @@ in
icon = "di:${nixservice}"; }]; icon = "di:${nixservice}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "mosquitto"; service = "mosquitto";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -88,7 +88,7 @@ in
}; };
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "zigbee2mqtt"; service = "zigbee2mqtt";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -104,7 +104,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.services = [{ homelab.glance.links.services = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -119,7 +119,7 @@ in
}; };
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "immich"; service = "immich";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -85,7 +85,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.services = [{ homelab.glance.links.services = [{
title = service; title = service;
url = "https://photos.${homelab.public_domain}"; url = "https://photos.${homelab.public_domain}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -93,7 +93,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir "/var/lib/redis-immich" ]; }; ${service} = { paths = [ cfg.data_dir "/var/lib/redis-immich" ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "jellyfin"; service = "jellyfin";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -81,7 +81,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://media.${homelab.public_domain}"; url = "https://media.${homelab.public_domain}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -89,7 +89,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,7 +2,7 @@
let let
service = "minecraft_recpro"; service = "minecraft_recpro";
cfg = config.modules.gameservers.${service}; cfg = config.gameservers.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
servers = { servers = {
velocity = { data_dir = "/var/lib/gameservers/minecraft_recpro/velocity"; ram = "2G"; }; velocity = { data_dir = "/var/lib/gameservers/minecraft_recpro/velocity"; ram = "2G"; };
@@ -12,7 +12,7 @@ let
}; };
in in
{ {
options.modules.gameservers.${service} = { options.gameservers.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
url = lib.mkOption { url = lib.mkOption {
type = lib.types.str; type = lib.types.str;
@@ -66,15 +66,13 @@ in
WorkingDirectory = srv.data_dir; WorkingDirectory = srv.data_dir;
UMask = "0007"; UMask = "0007";
ExecStart = "${pkgs.openjdk21}/bin/java -Xmx${srv.ram} -jar server.jar nogui"; ExecStart = "${pkgs.openjdk21}/bin/java -Xmx${srv.ram} -jar server.jar nogui";
# ExecStart = "${pkgs.tmux}/bin/tmux new-session -d -s mc-${name} '${pkgs.openjdk21}/bin/java -Xmx${srv.ram} -jar server.jar nogui'";
# ExecStop = "${pkgs.tmux}/bin/tmux send-keys -t mc-${name} C-c";
Restart = "on-failure"; Restart = "on-failure";
KillMode = "process"; KillMode = "process";
}; };
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}) servers; }) servers;
environment.systemPackages = with pkgs; [ openjdk21 mcrcon tmux ]; environment.systemPackages = with pkgs; [ openjdk21 mcrcon ];
services.mysql = { services.mysql = {
enable = true; enable = true;
@@ -96,25 +94,6 @@ in
# open firewall # open firewall
networking.firewall.allowedTCPPorts = [ 25777 25565 25566 25567 ]; networking.firewall.allowedTCPPorts = [ 25777 25565 25566 25567 ];
# # internal reverse proxy entry
# services.nginx.virtualHosts."${cfg.url}" = {
# forceSSL = true;
# sslCertificate = sec."ssl_blakedheld_crt".path;
# sslCertificateKey = sec."ssl_blakedheld_key".path;
# locations."/" = {
# proxyPass = "http://127.0.0.1:${toString cfg.port}";
# };
# };
# # external reverse proxy entry
# services.nginx.virtualHosts."${service}.blakedheld.xyz" = {
# forceSSL = true;
# sslCertificate = sec."ssl_blakedheld_crt".path;
# sslCertificateKey = sec."ssl_blakedheld_key".path;
# locations."/" = {
# proxyPass = "http://127.0.0.1:${toString cfg.port}";
# };
# };
#
sops.secrets = { sops.secrets = {
"velocity_forwarding" = { "velocity_forwarding" = {
owner = "minecraft"; owner = "minecraft";
@@ -130,7 +109,7 @@ in
}; };
# add to backups # add to backups
modules.system.backups.baks = lib.listToAttrs ( system.backups.baks = lib.listToAttrs (
lib.mapAttrsToList (srv_name: cfg: lib.mapAttrsToList (srv_name: cfg:
{ {
name = srv_name; # attribute key name = srv_name; # attribute key

View File

@@ -2,12 +2,12 @@
let let
service = "qbittorrent"; service = "qbittorrent";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -119,7 +119,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -127,7 +127,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -1,127 +0,0 @@
{
pkgs,
config,
lib,
...
}:
let
service = "";
cfg = config.modules.services.${service};
sec = config.sops.secrets;
homelab = config.modules.homelab;
in
{
options.modules.services.${service} = {
enable = lib.mkEnableOption "enables ${service}";
# set port options
port = lib.mkOption {
type = lib.types.int;
default = <port>;
description = "set port for ${service} (default: ${toString cfg.port}";
};
url = lib.mkOption {
type = lib.types.str;
default = "${service}.${homelab.base_domain}";
description = "set domain for ${service}";
};
data_dir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/${service}";
description = "set data directory for ${service}";
};
ids = lib.mkOption {
type = lib.types.int;
default = cfg.port;
description = "set uid and pid of ${service} user (matches port by default)";
};
backup = lib.mkOption {
type = lib.types.bool;
default = true;
description = "enable backups for ${service}";
};
};
config = lib.mkIf cfg.enable {
# declare ${service} group
users.groups.${service} = {
gid = lib.mkForce cfg.ids;
};
# declare ${service} user
users.users.${service} = {
description = "${service} server user";
uid = lib.mkForce cfg.ids;
isSystemUser = true;
home = cfg.data_dir;
createHome = true;
group = service;
extraGroups = [ "media" ];
};
# enable the ${service} service
services.${service} = {
enable = true;
openFirewall = true;
user = service;
group = service;
dataDir = cfg.data_dir;
settings = {
server.port = cfg.port;
};
};
# override umask to make permissions work out
systemd.services.${service}.serviceConfig = {
UMask = lib.mkForce "0007";
# User = service;
# Group = service;
};
# # open firewall
# networking.firewall.allowedTCPPorts = [ cfg.port ];
# add to caddy for reverse proxy
services.caddy.virtualHosts."${cfg.url}" = {
serverAliases = [ "${service}.${homelab.public_domain}" ];
extraConfig = ''
tls /etc/ssl/blakedheld.xyz.crt /etc/ssl/blakedheld.xyz.key
reverse_proxy 127.0.0.1:${toString cfg.port}
'';
};
#---------------------------------------------------------------------------
# # add to glance (public service)
# modules.services.glance.links.<category> = [{
# title = service;
# url = "https://${service}.${homelab.public_domain}";
# error-url = "http://${homelab.host_ip}:${toString cfg.port}";
# check-url = "http://${homelab.host_ip}:${toString cfg.port}";
# icon = "di:${service}"; }];
#---------------------------------------------------------------------------
# # add to glance (local service)
# modules.services.glance.links.<category> = [{
# title = service;
# url = "https://${cfg.url}";
# error-url = "http://${homelab.host_ip}:${toString cfg.port}";
# check-url = "http://${homelab.host_ip}:${toString cfg.port}";
# icon = "di:${service}"; }];
#---------------------------------------------------------------------------
#
# sops.secrets = {
# "${service}_" = {
# owner = ;
# group = ;
# };
# };
# add to backups
modules.system.backups.baks = {
${service} = {
paths = [ cfg.data_dir ];
};
};
};
}

View File

@@ -1,92 +0,0 @@
{ pkgs, config, lib, ... }:
/*
no longer in use, replaced by caddy if
wanting to use again here is the boilerplate
for whatt o put in for each service
# internal reverse proxy entry
services.nginx.virtualHosts."${cfg.url}" = {
forceSSL = true;
sslCertificate = sec."ssl_blakedheld_crt".path;
sslCertificateKey = sec."ssl_blakedheld_key".path;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString cfg.port}";
};
};
# external reverse proxy entry
services.nginx.virtualHosts."${service}.blakedheld.xyz" = {
forceSSL = true;
sslCertificate = sec."ssl_blakedheld_crt".path;
sslCertificateKey = sec."ssl_blakedheld_key".path;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString cfg.port}";
};
};
*/
let
cfg = config.modules.homelab.nginx-proxy;
sec = config.sops.secrets;
homelab = config.modules.homelab;
in
{
options.modules.homelab.nginx-proxy = {
enable = lib.mkEnableOption "enables nginx-proxy";
};
config = lib.mkIf cfg.enable {
# enable nginx proxy manager
services.nginx = {
enable = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
commonHttpConfig = ''
error_page 404 =302 https://www.youtube.com/watch?v=dQw4w9WgXcQ;
'';
};
# enable acme for auto ssl certs with lets encrypt
security.acme = {
acceptTerms = true;
defaults.email = "me@blakedheld.xyz";
};
systemd.tmpfiles.rules = [
"d /var/www/keys 0755 nginx nginx -"
];
# static entries
services.nginx.virtualHosts."key.${homelab.public_domain}" = {
forceSSL = true;
sslCertificate = sec."ssl_blakedheld_crt".path;
sslCertificateKey = sec."ssl_blakedheld_key".path;
root = "/var/www/keys";
locations."/" = {
index = "klefki_pub.asc";
extraConfig = ''
add_header Content-Disposition "attachment; filename=klefki_pub.asc";
default_type application/pgp-keys;
'';
};
};
# nginx secrets
sops.secrets = {
"ssl_blakedheld_crt" = {
restartUnits = [ "nginx.service" ];
owner = "nginx";
group = "nginx";
};
"ssl_blakedheld_key" = {
owner = "nginx";
group = "nginx";
};
"klefki_pub.asc" = {
owner = "nginx";
group = "nginx";
path = "/var/www/keys/klefki_pub.asc";
};
};
};
}

View File

@@ -1,13 +0,0 @@
{ pkgs, config, lib, ... }:
{
# services show up in glance in reverse import order lmao
imports = [
];
}

View File

@@ -2,12 +2,12 @@
let let
service = "uptime-kuma"; service = "uptime-kuma";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -81,7 +81,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.system = [{ homelab.glance.links.system = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -89,7 +89,7 @@ in
icon = "di:${service}"; }]; icon = "di:${service}"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,13 +2,13 @@
let let
service = "vaultwarden"; service = "vaultwarden";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
domain = "https://pass.blakedheld.xyz"; domain = "https://pass.blakedheld.xyz";
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -94,7 +94,7 @@ in
}; };
# add to glance # add to glance
modules.services.glance.links.services = [{ homelab.glance.links.services = [{
title = service; title = service;
url = "https://pass.${homelab.public_domain}"; url = "https://pass.${homelab.public_domain}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -109,7 +109,7 @@ in
}; };
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -2,12 +2,12 @@
let let
service = "yacreader"; service = "yacreader";
cfg = config.modules.services.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.modules.homelab; homelab = config.homelab;
in in
{ {
options.modules.services.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
# set port options # set port options
@@ -89,7 +89,7 @@ in
}; };
# add to glance local service # add to glance local service
modules.services.glance.links.mediastack = [{ homelab.glance.links.mediastack = [{
title = service; title = service;
url = "https://${cfg.url}"; url = "https://${cfg.url}";
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -97,7 +97,7 @@ in
icon = "di:yac-reader"; }]; icon = "di:yac-reader"; }];
# add to backups # add to backups
modules.system.backups.baks = { system.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = { paths = [ cfg.data_dir ]; };
}; };
}; };

View File

@@ -15,12 +15,12 @@ in a borg archive to the specified repo
*/ */
let let
cfg = config.modules.system.backups; cfg = config.system.backups;
sec = config.sops.secrets; sec = config.sops.secrets;
borg = "${pkgs.borgbackup}/bin/borg"; borg = "${pkgs.borgbackup}/bin/borg";
in in
{ {
options.modules.system.backups = { options.system.backups = {
enable = lib.mkEnableOption "enables backups with borg"; enable = lib.mkEnableOption "enables backups with borg";
baks = lib.mkOption { baks = lib.mkOption {
type = lib.types.attrsOf (lib.types.attrsOf (lib.types.listOf lib.types.path)); type = lib.types.attrsOf (lib.types.attrsOf (lib.types.listOf lib.types.path));

View File

@@ -1,102 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.modules.system.backups;
borg = "${pkgs.borgbackup}/bin/borg";
backup_paths = lib.unique config.modules.system.backups.paths;
passwd_file = config.sops.secrets."borg_passwd".path;
in
{
options.modules.system.backups = {
enable = lib.mkEnableOption "enables backups with borg";
paths = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [];
description = "list of directories to back up";
};
repo = lib.mkOption {
type = lib.types.path;
default = "/holocron/borg";
description = "borg repository path";
};
passphraseFile = lib.mkOption {
type = lib.types.path;
default = passwd_file;
description = "borg repository passphrase file";
};
};
config = lib.mkIf (cfg.enable && backup_paths != []) {
# systemd.tmpfiles.rules = [
# "d ${cfg.repo} 0755 root root"
# ];
systemd.services.backups = {
description = "backup service with borg!";
path = [ pkgs.borgbackup ];
serviceConfig = {
Type = "oneshot";
EnvironmentFile = config.modules.system.backups.passphraseFile;
# the actual script borg is using
ExecStart = pkgs.writeShellScript "borg-backup" ''
set -euo pipefail
export BORG_PASSPHRASE="$(cat ${passwd_file})"
export BORG_REPO="${cfg.repo}"
timestamp="$(date +'%Y-%m-%dT%H:%M:%S')"
# Initialize repo if it doesn't exist
if ! borg info "$BORG_REPO" >/dev/null 2>&1; then
echo "init borg repo at $BORG_REPO"
borg init --encryption=repokey "$BORG_REPO"
fi
# Create backup
echo "starting backup..."
borg create \
--verbose \
--filter AME \
--list \
--stats \
--show-rc \
--compression lzma,9 \
"$BORG_REPO::${toString config.networking.hostName}-$timestamp" \
${lib.concatStringsSep " " cfg.paths}
# Prune old backups according to retention policy
echo "Pruning old backups..."
borg prune -v --list "$BORG_REPO" \
--keep-daily=7 \
--keep-weekly=52 \
--keep-monthly=-1
echo "$timestamp - backup completed successfully."
'';
};
};
# create timer to run backups daily
systemd.timers.backups = {
description = "daily borg backup timer";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
};
};
# install borg binary
environment.systemPackages = [ pkgs.borgbackup ];
# declare secret for repo password
sops.secrets = {
"borg_passwd" = {
owner = "root";
group = "root";
};
};
};
}
# add to modules
# modules.system.backups.paths = lib.mkIf cfg.backups [ <path> ];

View File

@@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let let
cfg = config.modules.system.docker; cfg = config.system.docker;
in in
{ {
options.modules.system.docker = { options.system.docker = {
enable = lib.mkEnableOption "enables docker"; enable = lib.mkEnableOption "enables docker";
}; };

View File

@@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let let
cfg = config.modules.system.nvidia; cfg = config.system.nvidia;
in in
{ {
options.modules.system.nvidia = { options.system.nvidia = {
enable = lib.mkEnableOption "enables nvidia"; enable = lib.mkEnableOption "enables nvidia";
}; };

View File

@@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let let
cfg = config.modules.system.podman; cfg = config.system.podman;
in in
{ {
options.modules.system.podman = { options.system.podman = {
enable = lib.mkEnableOption "enables podman"; enable = lib.mkEnableOption "enables podman";
}; };

View File

@@ -1,12 +1,12 @@
{ pkgs, config, lib, inputs, ... }: { pkgs, config, lib, inputs, ... }:
let let
cfg = config.modules.system.sops; cfg = config.system.sops;
in in
{ {
imports = [ inputs.sops-nix.nixosModules.sops ]; imports = [ inputs.sops-nix.nixosModules.sops ];
options.modules.system.sops = { options.system.sops = {
enable = lib.mkEnableOption "enables sops"; enable = lib.mkEnableOption "enables sops";
}; };

View File

@@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let let
cfg = config.modules.system.ssh; cfg = config.system.ssh;
in in
{ {
options.modules.system.ssh = { options.system.ssh = {
enable = lib.mkEnableOption "enables ssh"; enable = lib.mkEnableOption "enables ssh";
}; };

View File

@@ -1,27 +1,12 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let let
cfg = config.modules.system.syncthing; cfg = config.system.syncthing;
in in
{ {
options.modules.system.syncthing = { options.system.syncthing = {
enable = lib.mkEnableOption "enables syncthing"; enable = lib.mkEnableOption "enables syncthing";
# mode = lib.mkOption {
# type = lib.types.enum [ "server" "client" ];
# default = "client";
# description = "whether syncthing should run as a client (user) or server (system-wide).";
# };
#
# data_dir = lib.mkOption {
# type = lib.types.str;
# default = if cfg.mode == "server"
# then "/var/lib/syncthing"
# else "/home/blake/.local/state/syncthing";
# description = "optional override for syncthing data directory.";
# };
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# systemd.tmpfiles.rules = lib.optionals (cfg.mode == "server") ["d /var/lib/syncthing 0775 blake blake -"]; # systemd.tmpfiles.rules = lib.optionals (cfg.mode == "server") ["d /var/lib/syncthing 0775 blake blake -"];

View File

@@ -4,10 +4,10 @@
lib, lib,
... ...
}: let }: let
cfg = config.modules.system.tailscale; cfg = config.system.tailscale;
authkey_file = config.sops.secrets."tailscale_authkey".path; authkey_file = config.sops.secrets."tailscale_authkey".path;
in { in {
options.modules.system.tailscale = { options.system.tailscale = {
enable = lib.mkEnableOption "enables tailscale"; enable = lib.mkEnableOption "enables tailscale";
}; };

View File

@@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let let
cfg = config.modules.system.vpn-confinement; cfg = config.system.vpn-confinement;
in in
{ {
options.modules.system.vpn-confinement = { options.system.vpn-confinement = {
enable = lib.mkEnableOption "enables vpn-confinement"; enable = lib.mkEnableOption "enables vpn-confinement";
# toggle for mullvad mexico w/ openvpn # toggle for mullvad mexico w/ openvpn

View File

@@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
let let
cfg = config.modules.system.vpns; cfg = config.system.vpns;
in in
{ {
options.modules.system.vpns = { options.system.vpns = {
enable = lib.mkEnableOption "enables vpns"; enable = lib.mkEnableOption "enables vpns";
# toggle for pia mexico w/ openvpn # toggle for pia mexico w/ openvpn