feat: minecraft server announcements

This commit is contained in:
s-prechtl 2025-03-31 23:33:27 +02:00
parent b7c237f798
commit ecd5b757a4
2 changed files with 20 additions and 3 deletions

View file

@ -38,7 +38,7 @@ in {
nix.settings.experimental-features = ["nix-command" "flakes"]; nix.settings.experimental-features = ["nix-command" "flakes"];
networking.firewall.allowedUDPPorts = [ 24454 ]; networking.firewall.allowedUDPPorts = [24454];
services.modded-minecraft-servers = { services.modded-minecraft-servers = {
# This is mandatory, sorry. # This is mandatory, sorry.
@ -91,5 +91,22 @@ in {
}; };
}; };
systemd.services.mc-announcement = {
description = "Minecraft Server Announcement";
serviceConfig = {
Type = "oneshot";
ExecStart = ''mcrcon -H localhost -P 25566 -p "whatisloveohbabydonthurtmedonthurtmenomore" '/title @a title {"text":"This server runs on NixOS","color":"blue","bold":true}'';
};
};
systemd.timers.mc-announcement = {
description = "Run Minecraft Announcement every hour";
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "hourly"; # Change this as needed
Persistent = true;
};
};
system.stateVersion = "24.11"; system.stateVersion = "24.11";
} }

View file

@ -6,9 +6,9 @@
lib, lib,
pkgs, pkgs,
... ...
}:let }: let
serverIP = "192.168.0.201"; serverIP = "192.168.0.201";
in{ in {
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix