feat(nixos): add Valheim service module
This commit is contained in:
@@ -66,35 +66,13 @@
|
|||||||
|
|
||||||
registry.address.pikachu.self = "10.23.10.102";
|
registry.address.pikachu.self = "10.23.10.102";
|
||||||
|
|
||||||
modules.services.steamcmd = {
|
modules.services.games.valheim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
steamDir = "/pikachu/data/steamcmd";
|
steamDir = "/pikachu/data/steamcmd";
|
||||||
serviceName = "valheim";
|
|
||||||
appId = 896660;
|
|
||||||
installDir = "/pikachu/data/servers/valheim/main";
|
installDir = "/pikachu/data/servers/valheim/main";
|
||||||
stateDir = "/pikachu/media/games/servers/valheim/main";
|
stateDir = "/pikachu/media/games/servers/valheim/main";
|
||||||
executable = "./valheim_server.x86_64";
|
serverName = "main";
|
||||||
arguments = [
|
password = "foobarbaz";
|
||||||
"-nographics"
|
|
||||||
"-batchmode"
|
|
||||||
"-name"
|
|
||||||
"main"
|
|
||||||
"-port"
|
|
||||||
"2456"
|
|
||||||
"-world"
|
|
||||||
"main"
|
|
||||||
"-savedir"
|
|
||||||
config.modules.services.steamcmd.stateDir
|
|
||||||
"-password"
|
|
||||||
"foobarbaz"
|
|
||||||
"-public"
|
|
||||||
"0"
|
|
||||||
];
|
|
||||||
udpPorts = [
|
|
||||||
2456
|
|
||||||
2457
|
|
||||||
2458
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
guests.actualbudget = {
|
guests.actualbudget = {
|
||||||
|
|||||||
94
configs/nixos/modules/services/games/valheim.nix
Normal file
94
configs/nixos/modules/services/games/valheim.nix
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options.modules.services.games.valheim = {
|
||||||
|
enable = lib.mkEnableOption "Valheim dedicated server";
|
||||||
|
|
||||||
|
steamDir = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
example = "/data/steamcmd";
|
||||||
|
description = "Directory where SteamCMD stores metadata and cache files.";
|
||||||
|
};
|
||||||
|
|
||||||
|
installDir = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
example = "/data/servers/valheim/main";
|
||||||
|
description = "Directory where SteamCMD installs the Valheim server files.";
|
||||||
|
};
|
||||||
|
|
||||||
|
stateDir = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
example = "/data/state/valheim/main";
|
||||||
|
description = "Directory where Valheim stores world data.";
|
||||||
|
};
|
||||||
|
|
||||||
|
serverName = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "valheim";
|
||||||
|
description = "Name shown for the Valheim server.";
|
||||||
|
};
|
||||||
|
|
||||||
|
worldName = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = config.modules.services.games.valheim.serverName;
|
||||||
|
defaultText = lib.literalExpression "config.modules.services.games.valheim.serverName";
|
||||||
|
description = "Valheim world name.";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 2456;
|
||||||
|
description = "Base UDP port for the Valheim server.";
|
||||||
|
};
|
||||||
|
|
||||||
|
password = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Valheim server password.";
|
||||||
|
};
|
||||||
|
|
||||||
|
public = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Whether to list the server publicly.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.modules.services.games.valheim.enable (
|
||||||
|
let
|
||||||
|
service = config.modules.services.games.valheim;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
modules.services.steamcmd = {
|
||||||
|
enable = true;
|
||||||
|
inherit (service) steamDir installDir stateDir;
|
||||||
|
serviceName = "valheim";
|
||||||
|
appId = 896660;
|
||||||
|
executable = "./valheim_server.x86_64";
|
||||||
|
arguments = [
|
||||||
|
"-nographics"
|
||||||
|
"-batchmode"
|
||||||
|
"-name"
|
||||||
|
service.serverName
|
||||||
|
"-port"
|
||||||
|
(toString service.port)
|
||||||
|
"-world"
|
||||||
|
service.worldName
|
||||||
|
"-savedir"
|
||||||
|
service.stateDir
|
||||||
|
"-password"
|
||||||
|
service.password
|
||||||
|
"-public"
|
||||||
|
(if service.public then "1" else "0")
|
||||||
|
];
|
||||||
|
udpPorts = [
|
||||||
|
service.port
|
||||||
|
(service.port + 1)
|
||||||
|
(service.port + 2)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user