Compare commits

...

28 Commits

Author SHA1 Message Date
a1118ba84f gn o/ <3 2025-10-14 23:47:09 -05:00
f25c552f76 going to sleep 2025-10-14 23:46:15 -05:00
09991e9684 finished motd 2025-10-14 23:34:50 -05:00
9347a392f1 better? 2025-10-14 23:29:40 -05:00
7a8a9e1c03 done 2025-10-14 23:22:24 -05:00
c84b11c4c4 done 2025-10-14 23:18:07 -05:00
835782ff53 hehe 2025-10-14 23:16:08 -05:00
7925577fe4 nah fr tho this time 2025-10-14 22:48:38 -05:00
65fdac2492 now fr 2025-10-14 22:42:25 -05:00
0c4008b544 fin for real? 2025-10-14 22:40:02 -05:00
4d3935527b add motd to everyone! 2025-10-14 22:29:43 -05:00
e32bdff7a8 fin 2025-10-14 22:25:25 -05:00
8321e6fe2c fix colors 2025-10-14 22:23:16 -05:00
69a671559a its done, deadass this time 2025-10-14 21:51:53 -05:00
e8a54ec95c deadass this time 2025-10-14 21:48:25 -05:00
7a211acea3 fix motd 2025-10-14 21:43:17 -05:00
1e8b341977 fix motd 2025-10-14 21:38:46 -05:00
a92f00a2ac testing motd 2025-10-14 21:30:11 -05:00
86d3855734 testing new motd 2025-10-14 21:27:07 -05:00
0057e3f757 testing 2025-10-14 21:25:41 -05:00
28856a1328 add motd 2025-10-14 21:06:17 -05:00
1782467549 adjust perms for copyparty 2025-10-14 20:45:55 -05:00
9c4f5716a2 real ip 2025-10-14 15:59:55 -05:00
d75853b9ee real ip 2025-10-14 15:55:53 -05:00
b688978b54 add config to copyparty 2025-10-14 15:46:16 -05:00
acadff6243 add copyparty 2025-10-14 13:27:16 -05:00
c01b0d8a99 add copyparty 2025-10-14 13:21:59 -05:00
9f6d24f885 add copyparty 2025-10-14 13:19:24 -05:00
29 changed files with 291 additions and 35 deletions

58
flake.lock generated
View File

@@ -1,5 +1,24 @@
{
"nodes": {
"copyparty": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1760309387,
"narHash": "sha256-yCjkJuQbt6DjdS1XJL2uwyLu1AcmDvlyMGojBq8Ua38=",
"owner": "9001",
"repo": "copyparty",
"rev": "d099e5e84e191d67a7bffa574ab39b6d0d4f6adf",
"type": "github"
},
"original": {
"owner": "9001",
"repo": "copyparty",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@@ -37,6 +56,21 @@
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1678901627,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@@ -75,11 +109,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1760139962,
"narHash": "sha256-4xggC56Rub3WInz5eD7EZWXuLXpNvJiUPahGtMkwtuc=",
"lastModified": 1748162331,
"narHash": "sha256-rqc2RKYTxP3tbjA+PB3VMRQNnjesrT0pEofXQTrMsS8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7e297ddff44a3cc93673bb38d0374df8d0ad73e4",
"rev": "7c43f080a7f28b2774f3b3f43234ca11661bf334",
"type": "github"
},
"original": {
@@ -103,6 +137,21 @@
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1760139962,
"narHash": "sha256-4xggC56Rub3WInz5eD7EZWXuLXpNvJiUPahGtMkwtuc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7e297ddff44a3cc93673bb38d0374df8d0ad73e4",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-25.05",
"type": "indirect"
}
},
"nvf": {
"inputs": {
"flake-compat": "flake-compat",
@@ -129,8 +178,9 @@
},
"root": {
"inputs": {
"copyparty": "copyparty",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs_2",
"nixpkgs-unstable": "nixpkgs-unstable",
"nvf": "nvf",
"sops-nix": "sops-nix",

View File

@@ -34,6 +34,7 @@ in
};
homelab = {
enable = true;
motd.enable = true;
gitea.enable = true;
glance.enable = true;
immich.enable = true;

View File

@@ -8,8 +8,10 @@
service = "copyparty";
cfg = config.holocron.${service};
sec = config.sops.secrets;
homelab = config.modules.homelab;
homelab = config.homelab;
in {
imports = [inputs.copyparty.nixosModules.default];
options.holocron.${service} = {
enable = lib.mkEnableOption "enables ${service}";
@@ -42,8 +44,7 @@ in {
};
config = lib.mkIf cfg.enable {
imports = [inputs.copyparty.nixosModules.default];
nixpkgs.overlays = [inputs.copyparty.overlays.default];
# declare ${service} group
users.groups.${service} = {
gid = lib.mkForce cfg.ids;
@@ -51,36 +52,57 @@ in {
# declare ${service} user
users.users.${service} = {
description = "${service} server user";
description = lib.mkForce "${service} server user";
uid = lib.mkForce cfg.ids;
isSystemUser = true;
home = cfg.data_dir;
createHome = true;
group = service;
extraGroups = [];
extraGroups = [ "media" "blake" ];
};
# enable the ${service} service
services.${service} = {
enable = true;
user = service;
group = service;
settings = {
i = "0.0.0.0";
p = [7902];
rproxy = 1;
};
accounts = {
blake = {
passwordFile = sec."copyparty_passwd".path;
};
};
groups = {
media = ["blake"];
};
volumes = {
};
flags = {
"/archives" = {
path = "/holocron/archives";
access = {
r = "*";
A = "blake";
};
};
"/media" = {
path = "/holocron/media";
access = {
r = "*";
w = "@media";
A = "blake";
};
};
"/users/blake" = {
path = "/holocron/users/blake";
access = {
A = "blake";
};
};
};
};
# # 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];
@@ -90,12 +112,13 @@ in {
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}
reverse_proxy 127.0.0.1:${toString cfg.port} {
}
'';
};
# add to glance (local service)
modules.services.glance.links.system = [
homelab.glance.links.system = [
{
title = service;
url = "https://${cfg.url}";
@@ -104,16 +127,16 @@ in {
icon = "di:${service}";
}
];
#
# sops.secrets = {
# "${service}_" = {
# owner = ;
# group = ;
# };
# };
sops.secrets = {
"${service}_passwd" = {
owner = service;
group = service;
};
};
# add to backups
modules.system.backups.baks = {
system.backups.baks = {
${service} = {
paths = [cfg.data_dir];
};

View File

@@ -2,6 +2,7 @@
pkgs,
config,
lib,
inputs,
...
}: {
# services show up in glance in reverse import order lmao
@@ -11,4 +12,5 @@
./zfs
./copyparty
];
}

View File

@@ -9,7 +9,7 @@ let
service = "";
cfg = config.modules.services.${service};
sec = config.sops.secrets;
homelab = config.modules.homelab;
homelab = config.homelab;
in
{
options.modules.services.${service} = {
@@ -94,7 +94,7 @@ in
#---------------------------------------------------------------------------
# # add to glance (public service)
# modules.services.glance.links.<category> = [{
# homelab.glance.links.<category> = [{
# title = service;
# url = "https://${service}.${homelab.public_domain}";
# error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -102,7 +102,7 @@ in
# icon = "di:${service}"; }];
#---------------------------------------------------------------------------
# # add to glance (local service)
# modules.services.glance.links.<category> = [{
# homelab.glance.links.<category> = [{
# title = service;
# url = "https://${cfg.url}";
# error-url = "http://${homelab.host_ip}:${toString cfg.port}";
@@ -118,7 +118,7 @@ in
# };
# add to backups
modules.system.backups.baks = {
system.backups.baks = {
${service} = {
paths = [ cfg.data_dir ];
};

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -21,6 +21,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -41,6 +41,7 @@ in
# the order determines the order in glance :3
imports = [
./motd
./glance
./caddy
./home/zigbee2mqtt

View File

@@ -41,6 +41,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {
@@ -75,6 +79,9 @@ in
SSH_PORT = cfg.ssh_port;
START_SSH_SERVER = true;
ENABLE_PUSH_CREATE_USER = true;
ALLOW_LOCALNETWORKS = true;
ALLOWED_DOMAINS = "10.10.0.10";
SKIP_TLS_VERIFY = true;
};
};

View File

@@ -60,6 +60,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
links = {
services = lib.mkOption {
type = lib.types.listOf lib.types.attrs;

View File

@@ -37,6 +37,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "podman-hass";
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "immich-server";
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -34,6 +34,10 @@ in
default = false;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "velocity";
};
};
config = lib.mkIf cfg.enable {

View File

@@ -0,0 +1,97 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf mkOption types filterAttrs mapAttrsToList;
cfg = config.homelab.motd;
# collect services to display
motd_list =
mapAttrsToList (_: v: v.motd)
(filterAttrs (_: v: v ? motd && v.motd != null) config.homelab);
in {
options.homelab.motd = {
enable = mkOption {
type = types.bool;
default = true;
description = "enable motd script";
};
};
config = mkIf cfg.enable {
environment.etc."motd".text = ''
#!/usr/bin/env bash
active=$'\033[1;34m'
inactive=$'\033[1;31m'
headings=$'\033[1;35m'
bold=$'\e[1m'
reset=$'\033[0m'
memory=`free -m | awk 'NR==2{printf "%s/%sMB (%.2f%%)\n", $3,$2,$3*100 / $2 }'`
load1=`cat /proc/loadavg | awk {'print $1'}`
load5=`cat /proc/loadavg | awk {'print $2'}`
load15=`cat /proc/loadavg | awk {'print $3'}`
uptime=`cat /proc/uptime | cut -f1 -d.`
up_days=$((uptime/60/60/24))
up_hours=$((uptime/60/60%24))
up_mins=$((uptime/60%60))
up_secs=$((uptime%60))
cpu_usage=$(top -bn1 | grep "Cpu(s)" | awk '{print 100 - $8 "%"}')
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
mem_avail=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
mem_used=$((mem_total - mem_avail))
mem_percent=$((100 * mem_used / mem_total))
uptime_fmt=$(uptime -p 2>/dev/null || cat /proc/uptime | awk '{print int($1/3600)"h "int(($1%3600)/60)"m"}')
printf "$bold welcome to $(hostname)!$reset\n"
printf "\n"
printf "$bold * %-20s$reset %s\n" "Release" "$nixos_version"
printf "$bold * %-20s$reset %s\n" "Kernel" "$(uname -rs)"
printf "\n"
printf "$bold * %-20s$reset %s\n" "CPU usage" "$load1, $load5, $load15 (1, 5, 15 min)"
printf "$bold * %-20s$reset %s\n" "Memory" "$memory"
printf "$bold * %-20s$reset %s\n" "System uptime" "$up_days days $up_hours hours $up_mins minutes $up_secs seconds"
echo
# --- services ---
echo -e "''${headings}homelab services:''${reset}"
${lib.concatStringsSep "\n" (map (service: ''
if systemctl list-units --type=service --all | grep -q "${service}"; then
status=$(systemctl is-active ${service} 2>/dev/null)
if [ "$status" = "active" ]; then
printf "%-26s%s\n" "''${active}${service}''${reset}" "running"
else
printf "%-26s%s\n" "''${active}${service}''${reset}" "not running"
fi
else
printf "%-26s%s\n" "''${active}${service}''${reset}" "not found"
fi
'')
motd_list)}
echo
# --- gameservers ---
echo -e "''${headings}gameservers:''${reset}"
for service in velocity smp superflat bento; do
status=$(systemctl is-active $service 2>/dev/null)
if [ "$status" = "active" ]; then
printf "%-26s%s\n" "''${active}$service''${reset}" "running"
else
printf "%-26s%s\n" "''${active}$service''${reset}" "not running"
fi
done
echo
'';
environment.etc."motd".mode = "0755";
programs.bash.interactiveShellInit = ''
/etc/motd
'';
};
}

View File

@@ -46,6 +46,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -37,6 +37,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -36,6 +36,10 @@ in
default = true;
description = "enable backups for ${service}";
};
motd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = service;
};
};
config = lib.mkIf cfg.enable {

View File

@@ -148,7 +148,7 @@ in
};
# install borg binary
environment.systemPackages = with pkgs; [ borgbackup ];
environment.systemPackages = with pkgs; [ borgbackup tree ];
# declare secret for repo password
sops.secrets = {

View File

@@ -20,6 +20,8 @@ minecraft_recpro_db_passwd: ENC[AES256_GCM,data:dPAkdEX0hBigo/lND2r3ShxnS4Jc5wTI
#ENC[AES256_GCM,data:nbB5Cd7i/KTMCjCzcX8o1sxREZQ/gLAG,iv:iyuO2erxdJM08WHJBjKuNIXYxVhH7rfyOLTcGCcGqNQ=,tag:UeDszimXv8kQUmDetLeFqg==,type:comment]
mosquitto_hashed_passwd: ENC[AES256_GCM,data:k1Lnr8ZTDpzXMoRmRH61X41boX/D8Rm1KPh7x3/IHFo+XKIOUQns53iA+7e7Ohp8uWSthDlOk4SlRvTXdUNiEz7Zmw9LYwy7BHbwpNo2pFApAye1ORPrMrhMUkUfgBgc8oqPPyRXmmrOAFp6GBbRhg==,iv:D8wQL9iF0rqOte5X24kDTVjYUJXbZSLz0Ykbp0HqmYo=,tag:RUCgO1uKPIdumSo563cg1Q==,type:str]
mosquitto_passwd.yaml: ENC[AES256_GCM,data:9xwHiUaQ6zG/4rkRemXtbRJ/KEV4yajqyYlcXRR1eAQ2XijYOzitPjt53h3FPqp5rxl6dJerXNH5CiZZK3t1l339NxNseJFGVmIHitWJxNmGJMlG3M8r8Q==,iv:C6WWZuVkYaasB2pol3uf4Mc3d/lDEgt2pKX+dHl/Cr4=,tag:jYTC6RKF2TzDSwSUh6D8zQ==,type:str]
#ENC[AES256_GCM,data:3oMbbBSrbjrqsdiON1ENB8JeKW0=,iv:+/eL/51OA+VHbkWWSNzQId5BlxnMm+5NBA0uKw010Tk=,tag:vBJpCYmvFivBYIKatDWgHw==,type:comment]
copyparty_passwd: ENC[AES256_GCM,data:I3UYy4nJ0B6RnIp661O0VVqEmxloxxcroBKmNFcgoQ==,iv:sWkPfKqomrNaYFZbn+BeQEugRMlaqi1qJhELqfsGCik=,tag:Sgz56ZW9EY49zfwFDN7whg==,type:str]
#ENC[AES256_GCM,data:3ATkokBKeOp97uORzaePROrKKfG94ic=,iv:MNJRh6Vrso1heqNUJc0M4xGNcMLGwcF9IzoiQ5+SS+g=,tag:xj8Actwkirvq4GE+Ly1M9w==,type:comment]
vpncon_mex_config: ENC[AES256_GCM,data:4i356X97sBoRliskmh5ewcEwZHkpo37IhPcemKVdWJgWFWtA+AhTeEo4KQ3dRA1H/n8VjVX7CKZKPDxpmHfcUlnTLT0agtOjjyjf60kWoL8noJqcbDB4wGiYT910rPToVnYMFk0H2lerYp+/n2bhg8BHxn++VlPOOZsgla4El+FNXUqhScpAawySPSF36ocdRJ3r3DuflIhnTBXxSZukMf9Ux1uaFldSG7KasCQlStKy9O2Odd2AvAuGXOHch5KecRPT3WnonQ8oDJpuxbeaosLmtJKHL9oeXHPId2Unc1GNoOpnDC3Y/xGnrPb9WFXWYOSQ/1A3mNKwnVq0FEhluVbqodES4PVIlCS0koiQJq15P15G2z0jO+OhAQrRI5vn3Fki5A==,iv:tQvTpzhl7F7niigAXl61FMHbg6QqI2R7yGD/C2lwOR4=,tag:c+CVLd6lGrAfm38pFXOXTw==,type:str]
#ENC[AES256_GCM,data:ep/Z5O6RNFwTd0I5hvtk5DP9,iv:M7sclKcTR+IfCEsvz0lZaoZBRZlQsN/FhwuzFNXgVew=,tag:Ddo3Qf8tMBX9Amt7C9m5FA==,type:comment]
@@ -39,7 +41,7 @@ sops:
U0tmdFBuZnJES3piOTZNV0VKQmQ0eVUKCWRQ/flLzmpC64WyLoipklZBmrkpYiUg
PRu+itNolpPTHm96pe+P93g2iP0wgekG0cX21wkiU2xaLF3dY2FEIA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2025-10-12T00:27:54Z"
mac: ENC[AES256_GCM,data:10/OeCnswKYlpPGOxAYwwZRza8Iow6g4RRI9kESFEdnG+VNPuAblDLQ/5YRlf29/cWCWczxfeoCIrUYSjh7zeQgRQ5KSsCTVovJnY0svSnKCN84Mwe6wfOYIaCCbVqB4T8lqaaAHlA2aQEJ/M3aw0lyyYY3b/HCgHWY/5jQzyGE=,iv:xxW2nXBT3uMEKOffqsIVBP5NXAaiv2me2wcaXSn6wxU=,tag:y97BkXOj6rSkki5l0DpIeQ==,type:str]
lastmodified: "2025-10-14T19:45:38Z"
mac: ENC[AES256_GCM,data:bxMEJTiMZQo4eXmTzamCQALYSdAj7buciSra1kozyahbeD0xkDco5Pgr6AuvnITKcxvINBfS7qJ0GJCwkQ4DNtPqt/b2T9P8QvtYq7iKMbDou81Vni4C24IlHrh/oSl+gF/8G8KVKjeCc2g94xaMrHZfpdSyceNKkr/vSoOkyrk=,iv:Mn46bU1fFxztgFjYSNkGIz4Izi4CiDRlonizfuxNU50=,tag:SlYtnP2bdbwogeQ8h1rHEQ==,type:str]
unencrypted_suffix: _unencrypted
version: 3.11.0

View File

@@ -65,6 +65,7 @@ alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# scripts
alias motd='sh /etc/motd'
alias rebuild='sh ~/.nix/bin/rebuild.sh'
alias perms='sudo sh ~/.nix/bin/perms.sh'
alias bb='sudo sh ~/.nix/bin/backup_browse.sh'