add earth.nix mc server *2

This commit is contained in:
k3t
2026-06-27 14:43:37 -06:00
parent 0ff335dd5d
commit 65a190e115
2 changed files with 36 additions and 0 deletions
@@ -0,0 +1,35 @@
{ config, pkgs, ... }:
{
systemd.services.minecraft-container = {
description = "Minecraft Server [earth.nix]";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
serviceConfig = {
ExecStart = ''
${pkgs.podman}/bin/podman run \
--rm \
--name minecraft-server \
-v /var/lib/minecraft/earth.nix:/data \
-p 25565:25565 \
-p 24454:24454/udp \
ghcr.io/graalvm/graalvm-community:17 \
/data/run.sh
'';
ExecStop = "${pkgs.podman}/bin/podman stop minecraft-server";
Restart = "always";
RestartSec = "10s";
};
# Ensure the directory exists
preStart = ''
mkdir -p /var/lib/minecraft/earth.nix/
'';
wantedBy = [ "multi-user.target" ];
};
# Give Podman permission to access persistent storage
systemd.tmpfiles.rules = [
"d /var/lib/minecraft/earth.nix 0755 root root"
];
}