50 lines
1.2 KiB
Nix
50 lines
1.2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
{
|
|
microvm.vms.valheim = {
|
|
autoStart = true;
|
|
memorySize = 4096;
|
|
vcpu = 2;
|
|
|
|
forwardPorts = [
|
|
{ from = "host"; hostPort = 2456; guestPort = 2456; proto = "udp"; }
|
|
{ from = "host"; hostPort = 2457; guestPort = 2457; proto = "udp"; }
|
|
];
|
|
|
|
# NOTE: For games with large save files, choose a path in "/tank" for
|
|
# storage.
|
|
sharedDirectories = [
|
|
{
|
|
hostPath = "/srv/game-data-valheim";
|
|
guestPath = "/data";
|
|
tag = "valheim-data";
|
|
readOnly = false;
|
|
}
|
|
];
|
|
|
|
packages = [ pkgs.steamcmd pkgs.steam-run ];
|
|
|
|
users.users.valheim = {
|
|
isNormalUser = true;
|
|
home = "/home/valheim";
|
|
extraGroups = [ "wheel" ];
|
|
};
|
|
|
|
systemd.services.valheim = {
|
|
description = "Valheim Dedicated Server";
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig = {
|
|
workingDirectory = "/data";
|
|
ExecStart = ''
|
|
${pkgs.steam-run}/bin/steam-run ./valheim_server.x86_64 \
|
|
-name "Valheim NixOS" \
|
|
-port 2456 \
|
|
-world "FlatEarth" \
|
|
-password "secret" \
|
|
-public 1
|
|
'';
|
|
Restart = "always";
|
|
User = "valheim";
|
|
};
|
|
};
|
|
};
|
|
}
|