nixos/services/game-servers.nix

70 lines
2 KiB
Nix
Raw Normal View History

2026-01-20 19:53:42 +00:00
{ config, pkgs, lib, ... }:
{
2026-01-25 12:35:18 +00:00
config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") {
## <----- V-RISING ----> ##
virtualisation.docker.enable = true;
systemd.tmpfiles.rules = [
"d /var/lib/v-rising 0755 root root -"
"d /var/lib/v-rising/server 0755 root root -"
"d /var/lib/v-rising/persistentdata 0755 root root -"
];
virtualisation.oci-containers = {
backend = "docker";
containers.v-rising = {
image = "trueosiris/vrising:latest";
volumes = [
"/var/lib/v-rising/server:/mnt/vrising/server"
"/var/lib/v-rising/persistentdata:/mnt/vrising/persistentdata"
];
ports = [
"9876:9876/udp"
"9877:9877/udp"
];
environment = {
TZ = "Europe/Stockholm";
SERVERNAME = "FredOS V-Rising";
WORLDNAME = "world1";
# SERVERPASSWORD = "";
};
};
};
2026-01-25 12:35:18 +00:00
## <----- HYTALE ----> ##
2026-01-25 16:19:42 +00:00
systemd.services.hytale-server = {
description = "Hytale Dedicated Server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
2026-01-25 16:38:45 +00:00
path = with pkgs; [ bash jdk unzip gawk gnugrep coreutils screen ]; # Added screen
2026-01-25 16:27:28 +00:00
2026-01-25 16:19:42 +00:00
environment = {
2026-01-25 16:38:45 +00:00
HYTALE_MEMORY = "8G";
2026-01-25 16:19:42 +00:00
};
serviceConfig = {
2026-01-25 16:38:45 +00:00
Type = "forking"; # Changed from "simple"
2026-01-25 16:19:42 +00:00
User = "fred";
Group = "users";
WorkingDirectory = "/home/fred/docker/hytale-server/Server";
2026-01-25 16:38:45 +00:00
ExecStart = "${pkgs.screen}/bin/screen -dmS hytale /home/fred/docker/hytale-server/start-hytale.sh";
ExecStop = "${pkgs.screen}/bin/screen -S hytale -X stuff 'stop^M'";
RemainAfterExit = "yes";
2026-01-25 16:19:42 +00:00
Restart = "on-failure";
RestartSec = "10s";
TimeoutStopSec = "30s";
# Security hardening
NoNewPrivileges = true;
PrivateTmp = true;
};
};
networking.firewall.allowedUDPPorts = [ 5520 9876 9877 ];
2026-01-25 12:35:18 +00:00
};
2026-01-20 19:53:42 +00:00
}