conditional motd in the motd config

This commit is contained in:
2026-06-14 09:01:58 -05:00
parent 5890c3e461
commit 7c18ecebab
3 changed files with 30 additions and 12 deletions
+25 -7
View File
@@ -10,7 +10,24 @@
# collect services to display
motd_list =
mapAttrsToList (_: v: v.motd)
(filterAttrs (_: v: v ? motd && v.motd != null) config.homelab);
(filterAttrs (
_: v:
(v.enable or false)
&& v ? motd
&& v.motd != null
)
config.homelab);
motd_gs_list = lib.concatLists (
mapAttrsToList (_: v: v.motd_gs)
(filterAttrs (
_: v:
(v.enable or false)
&& v ? motd_gs
&& v.motd_gs != null
)
config.gameservers)
);
in {
options.homelab.motd = {
enable = mkOption {
@@ -78,15 +95,16 @@ in {
# --- gameservers ---
echo -e "''${headings}gameservers:''${reset}"
for service in velocity smp superflat bento; do
status=$(systemctl is-active $service 2>/dev/null)
${lib.concatStringsSep "\n" (map (service: ''
status=$(systemctl is-active ${service} 2>/dev/null)
if [ "$status" = "active" ]; then
printf "%-32s%s\n" " ''${active}[$service]''${reset}" "running"
printf "%-32s%s\n" " ''${active}[${service}]''${reset}" "running"
else
printf "%-32s%s\n" " ''${active}[$service]''${reset}" "not running"
printf "%-32s%s\n" " ''${active}[${service}]''${reset}" "not running"
fi
done
echo
'')
motd_gs_list)}
'';
environment.etc."motd".mode = "0755";