test automatical inculstion in motd

This commit is contained in:
2026-06-14 07:56:34 -05:00
parent 85a97ddb47
commit fcb8961c69
3 changed files with 35 additions and 25 deletions
@@ -38,7 +38,10 @@ in {
}; };
motd = lib.mkOption { motd = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = "velocity"; default =
if cfg.enable
then "velocity"
else null;
}; };
backup_repo = lib.mkOption { backup_repo = lib.mkOption {
type = lib.types.path; type = lib.types.path;
@@ -1,12 +1,14 @@
{ pkgs, config, lib, ... }: {
pkgs,
let config,
lib,
...
}: let
service = "audiobookshelf"; service = "audiobookshelf";
cfg = config.homelab.${service}; cfg = config.homelab.${service};
sec = config.sops.secrets; sec = config.sops.secrets;
homelab = config.homelab; homelab = config.homelab;
in in {
{
options.homelab.${service} = { options.homelab.${service} = {
enable = lib.mkEnableOption "enables ${service}"; enable = lib.mkEnableOption "enables ${service}";
@@ -38,24 +40,26 @@ in
}; };
motd = lib.mkOption { motd = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = service; default =
if cfg.enable
then service
else null;
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# declare ${service} group # declare ${service} group
users.groups.${service} = { gid = lib.mkForce cfg.ids; }; users.groups.${service} = {gid = lib.mkForce cfg.ids;};
# declare ${service} user # declare ${service} user
users.users.${service} = { users.users.${service} = {
description = "${service} server user"; description = "${service} server user";
uid = lib.mkForce cfg.ids; uid = lib.mkForce cfg.ids;
isSystemUser = true; isSystemUser = true;
# home = cfg.data_dir; # home = cfg.data_dir;
createHome = true; createHome = true;
group = service; group = service;
extraGroups = [ "media" ]; extraGroups = ["media"];
}; };
# enable the ${service} service # enable the ${service} service
@@ -64,7 +68,7 @@ in
openFirewall = true; openFirewall = true;
user = service; user = service;
group = service; group = service;
# dataDir = cfg.data_dir; # dataDir = cfg.data_dir;
host = "0.0.0.0"; host = "0.0.0.0";
port = cfg.port; port = cfg.port;
}; };
@@ -72,16 +76,16 @@ in
# override umask to make permissions work out # override umask to make permissions work out
systemd.services.${service}.serviceConfig = { systemd.services.${service}.serviceConfig = {
UMask = lib.mkForce "0007"; UMask = lib.mkForce "0007";
# User = service; # User = service;
# Group = service; # Group = service;
}; };
# # open firewall # # open firewall
# networking.firewall.allowedTCPPorts = [ cfg.port ]; # networking.firewall.allowedTCPPorts = [ cfg.port ];
# add to caddy for reverse proxy # add to caddy for reverse proxy
services.caddy.virtualHosts."${cfg.url}" = { services.caddy.virtualHosts."${cfg.url}" = {
serverAliases = [ "abs.${homelab.public_domain}" ]; serverAliases = ["abs.${homelab.public_domain}"];
extraConfig = '' extraConfig = ''
tls internal tls internal
reverse_proxy 127.0.0.1:${toString cfg.port} { reverse_proxy 127.0.0.1:${toString cfg.port} {
@@ -90,16 +94,19 @@ in
}; };
# add to glance public service # add to glance public service
homelab.glance.links.mediastack = [{ homelab.glance.links.mediastack = [
title = service; {
url = "https://abs.${homelab.base_domain}"; title = service;
error-url = "http://${homelab.host_ip}:${toString cfg.port}"; url = "https://abs.${homelab.base_domain}";
check-url = "http://${homelab.host_ip}:${toString cfg.port}"; error-url = "http://${homelab.host_ip}:${toString cfg.port}";
icon = "di:${service}"; }]; check-url = "http://${homelab.host_ip}:${toString cfg.port}";
icon = "di:${service}";
}
];
# add to backups # add to backups
homelab.backups.baks = { homelab.backups.baks = {
${service} = { paths = [ cfg.data_dir ]; }; ${service} = {paths = [cfg.data_dir];};
}; };
}; };
} }
+1 -1
View File
@@ -78,7 +78,7 @@ in {
# --- gameservers --- # --- gameservers ---
echo -e "''${headings}gameservers:''${reset}" echo -e "''${headings}gameservers:''${reset}"
for service in velocity smp superflat bento cobblemon; do for service in velocity smp superflat bento; do
status=$(systemctl is-active $service 2>/dev/null) status=$(systemctl is-active $service 2>/dev/null)
if [ "$status" = "active" ]; then if [ "$status" = "active" ]; then
printf "%-32s%s\n" " ''${active}[$service]''${reset}" "running" printf "%-32s%s\n" " ''${active}[$service]''${reset}" "running"