conditional motd in the motd config
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
../../../modules/homelab
|
||||
#../../../modules/gameservers/srcds
|
||||
../../../modules/gameservers/minecraft_recpro
|
||||
#../../../modules/gameservers/minecraft_modded
|
||||
../../../modules/gameservers/minecraft_modded
|
||||
];
|
||||
|
||||
home-manager.users.blake.imports = [
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
gameservers = {
|
||||
minecraft_recpro.enable = true;
|
||||
#minecraft_modded.enable = false;
|
||||
minecraft_modded.enable = false;
|
||||
};
|
||||
|
||||
# boot (systemd is going on me)
|
||||
|
||||
@@ -49,9 +49,9 @@ in {
|
||||
default = false;
|
||||
description = "enable backups for ${service}";
|
||||
};
|
||||
motd = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = "velocity";
|
||||
motd_gs = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.listOf lib.types.str);
|
||||
default = ["velocity" "smp" "superflat" "bento"];
|
||||
};
|
||||
backup_repo = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user