feat(nixos): run Valheim in a guest

This commit was merged in pull request #37.
This commit is contained in:
2026-09-10 10:16:27 -04:00
parent 5758a781d8
commit 8bd9ff166e
6 changed files with 158 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
{
config,
lib,
pkgs,
...
}:
{
@@ -37,9 +38,9 @@
description = "Base UDP port for the Valheim server.";
};
password = lib.mkOption {
type = lib.types.str;
description = "Valheim server password.";
passwordFile = lib.mkOption {
type = lib.types.path;
description = "Runtime file containing the Valheim server password.";
};
};
@@ -47,6 +48,12 @@
config = lib.mkIf config.modules.services.games.valheim.enable (
let
service = config.modules.services.games.valheim;
startScript = pkgs.writeShellScript "valheim-start" ''
set -eu
password="$(${pkgs.coreutils}/bin/tr -d '\n' < ${lib.escapeShellArg service.passwordFile})"
exec ./valheim_server.x86_64 "$@" -password "$password"
'';
in
{
modules.services.steamcmd = {
@@ -54,7 +61,7 @@
inherit (service) steamDir installDir stateDir;
serviceName = "valheim";
appId = 896660;
executable = "./valheim_server.x86_64";
executable = "${startScript}";
arguments = [
"-nographics"
"-batchmode"
@@ -66,8 +73,6 @@
service.serverName
"-savedir"
service.stateDir
"-password"
service.password
"-public"
"0"
];