add earth.nix mc server *2
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
imports =
|
imports =
|
||||||
[ # Include the results of the hardware scan.
|
[ # Include the results of the hardware scan.
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
./gameservers.d/minecraft/earth.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "NixGame";
|
networking.hostName = "NixGame";
|
||||||
|
|||||||
@@ -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"
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user