Add 7 Days to Die dedicated server container; drop V-Rising

Enables the previously-disabled game-servers module with a new 7DTD
container (vinanrra/7dtd-server) on ports 26900 TCP + 26900-26902 UDP.
A oneshot systemd service waits for LGSM's first install to drop
sdtdserver.xml, then patches in the server name, password, and
random-gen world before restarting the container. V-Rising is removed
— the module hadn't been imported, so this just drops dead code.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
ediblerope 2026-04-17 22:28:49 +01:00
parent d80ccf4e6d
commit c05f986e1c
2 changed files with 68 additions and 50 deletions

View file

@ -18,7 +18,7 @@
# Services # # Services #
./services/server-permissions.nix ./services/server-permissions.nix
#./services/game-servers.nix ./services/game-servers.nix
./services/qbittorrent-nox.nix ./services/qbittorrent-nox.nix
./services/nginx.nix ./services/nginx.nix
./services/go2rtc.nix ./services/go2rtc.nix

View file

@ -1,71 +1,89 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ {
config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") { config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") {
## <----- V-RISING ----> ##
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d /var/lib/v-rising 0755 root root -" "d /var/lib/7dtd 0755 root root -"
"d /var/lib/v-rising/server 0755 root root -" "d /var/lib/7dtd/saves 0755 root root -"
"d /var/lib/v-rising/persistentdata 0755 root root -" "d /var/lib/7dtd/serverfiles 0755 root root -"
"d /var/lib/7dtd/lgsm 0755 root root -"
"d /var/lib/7dtd/log 0755 root root -"
"d /var/lib/7dtd/backups 0755 root root -"
]; ];
## <----- 7 DAYS TO DIE ----> ##
virtualisation.oci-containers = { virtualisation.oci-containers = {
backend = "docker"; backend = "docker";
containers.v-rising = { containers."7dtd" = {
image = "trueosiris/vrising:latest"; image = "vinanrra/7dtd-server:latest";
entrypoint = "/bin/bash";
cmd = [ "-c" "sed -i 's/\\r$//' /start.sh && /start.sh" ];
volumes = [ volumes = [
"/var/lib/v-rising/server:/mnt/vrising/server" "/var/lib/7dtd/saves:/home/sdtdserver/.local/share/7DaysToDie"
"/var/lib/v-rising/persistentdata:/mnt/vrising/persistentdata" "/var/lib/7dtd/serverfiles:/home/sdtdserver/serverfiles"
"/var/lib/7dtd/lgsm:/home/sdtdserver/lgsm/config-lgsm/sdtdserver"
"/var/lib/7dtd/log:/home/sdtdserver/log"
"/var/lib/7dtd/backups:/home/sdtdserver/lgsm/backup"
]; ];
ports = [ ports = [
"9876:9876/udp" "26900:26900/tcp"
"9877:9877/udp" "26900:26900/udp"
"26901:26901/udp"
"26902:26902/udp"
]; ];
environment = { environment = {
TZ = "Europe/Stockholm"; START_MODE = "1";
SERVERNAME = "FredOS V-Rising"; VERSION = "stable";
WORLDNAME = "world1"; TimeZone = "Europe/Stockholm";
# SERVERPASSWORD = ""; TEST_ALERT = "NO";
}; };
}; };
}; };
## <----- HYTALE ----> ## systemd.services."7dtd-configure" = {
# systemd.services.hytale-server = { description = "Patch 7DTD sdtdserver.xml on first install";
# description = "Hytale Dedicated Server"; after = [ "docker-7dtd.service" ];
# wantedBy = [ "multi-user.target" ]; wants = [ "docker-7dtd.service" ];
# after = [ "network.target" ]; wantedBy = [ "multi-user.target" ];
# path = with pkgs; [ gnused coreutils systemd ];
# path = with pkgs; [ bash jdk unzip gawk gnugrep coreutils screen ]; script = ''
# MARKER=/var/lib/7dtd/.configured
# environment = { CONFIG=/var/lib/7dtd/serverfiles/sdtdserver.xml
# HYTALE_MEMORY = "8G"; if [ -f "$MARKER" ]; then
# }; echo "Already configured; skipping."
# exit 0
# serviceConfig = { fi
# Type = "forking"; echo "Waiting for $CONFIG (install can take 15+ minutes on first boot)..."
# User = "fred"; for i in $(seq 1 180); do
# Group = "users"; [ -f "$CONFIG" ] && break
# WorkingDirectory = "/home/fred/docker/hytale-server/Server"; sleep 10
# ExecStart = "${pkgs.screen}/bin/screen -dmS hytale /home/fred/docker/hytale-server/start-hytale.sh"; done
# ExecStop = "${pkgs.screen}/bin/screen -S hytale -X stuff 'stop^M'"; if [ ! -f "$CONFIG" ]; then
# RemainAfterExit = "yes"; echo "Timed out waiting for $CONFIG; will retry next boot."
# Restart = "on-failure"; exit 1
# RestartSec = "10s"; fi
# TimeoutStopSec = "30s";
#
# # Security hardening
# NoNewPrivileges = true;
# PrivateTmp = true;
# };
# };
networking.firewall.allowedUDPPorts = [ 9876 9877 ]; set_prop() {
sed -i "s|<property name=\"$1\"[^/]*value=\"[^\"]*\"|<property name=\"$1\" value=\"$2\"|" "$CONFIG"
}
set_prop ServerName "Nordhammer.it"
set_prop ServerPassword "DaveSmells"
set_prop GameWorld "RWG"
set_prop WorldGenSeed "Nordhammer"
set_prop WorldGenSize "8192"
set_prop GameName "Nordhammer"
touch "$MARKER"
echo "Patched; restarting container to apply."
systemctl restart docker-7dtd.service
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
};
networking.firewall.allowedTCPPorts = [ 26900 ];
networking.firewall.allowedUDPPorts = [ 26900 26901 26902 ];
}; };
} }