conditional motd in the motd config
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
../../../modules/homelab
|
../../../modules/homelab
|
||||||
#../../../modules/gameservers/srcds
|
#../../../modules/gameservers/srcds
|
||||||
../../../modules/gameservers/minecraft_recpro
|
../../../modules/gameservers/minecraft_recpro
|
||||||
#../../../modules/gameservers/minecraft_modded
|
../../../modules/gameservers/minecraft_modded
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.users.blake.imports = [
|
home-manager.users.blake.imports = [
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
|
|
||||||
gameservers = {
|
gameservers = {
|
||||||
minecraft_recpro.enable = true;
|
minecraft_recpro.enable = true;
|
||||||
#minecraft_modded.enable = false;
|
minecraft_modded.enable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
# boot (systemd is going on me)
|
# boot (systemd is going on me)
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ in {
|
|||||||
default = false;
|
default = false;
|
||||||
description = "enable backups for ${service}";
|
description = "enable backups for ${service}";
|
||||||
};
|
};
|
||||||
motd = lib.mkOption {
|
motd_gs = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.str;
|
type = lib.types.nullOr (lib.types.listOf lib.types.str);
|
||||||
default = "velocity";
|
default = ["velocity" "smp" "superflat" "bento"];
|
||||||
};
|
};
|
||||||
backup_repo = lib.mkOption {
|
backup_repo = lib.mkOption {
|
||||||
type = lib.types.path;
|
type = lib.types.path;
|
||||||
|
|||||||
@@ -10,7 +10,24 @@
|
|||||||
# collect services to display
|
# collect services to display
|
||||||
motd_list =
|
motd_list =
|
||||||
mapAttrsToList (_: v: v.motd)
|
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 {
|
in {
|
||||||
options.homelab.motd = {
|
options.homelab.motd = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
@@ -78,15 +95,16 @@ in {
|
|||||||
|
|
||||||
# --- gameservers ---
|
# --- gameservers ---
|
||||||
echo -e "''${headings}gameservers:''${reset}"
|
echo -e "''${headings}gameservers:''${reset}"
|
||||||
for service in velocity smp superflat bento; do
|
${lib.concatStringsSep "\n" (map (service: ''
|
||||||
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"
|
||||||
else
|
else
|
||||||
printf "%-32s%s\n" " ''${active}[$service]''${reset}" "not running"
|
printf "%-32s%s\n" " ''${active}[${service}]''${reset}" "not running"
|
||||||
fi
|
fi
|
||||||
done
|
'')
|
||||||
echo
|
motd_gs_list)}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
environment.etc."motd".mode = "0755";
|
environment.etc."motd".mode = "0755";
|
||||||
|
|||||||
Reference in New Issue
Block a user