feat(nixos): run Valheim in a guest
This commit was merged in pull request #37.
This commit is contained in:
@@ -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"
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user