36 lines
950 B
Nix
36 lines
950 B
Nix
{ 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"
|
|
];
|
|
}
|