summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2021-03-11 20:40:01 -0500
committerKjetil Orbekk <kj@orbekk.com>2021-03-11 20:40:01 -0500
commit09ec7fa5a3038bdf2762ee73650b554d14d89081 (patch)
treede107f771b13b48f6fbeb1d16f141707ac4f84e2 /modules
parent6483d5e380a57bbde2e629735b4461b64fab3cfc (diff)
dragon valheim
Diffstat (limited to 'modules')
-rw-r--r--modules/valheim.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/valheim.nix b/modules/valheim.nix
new file mode 100644
index 0000000..bdfb813
--- /dev/null
+++ b/modules/valheim.nix
@@ -0,0 +1,47 @@
+{ config, lib, pkgs, ... }:
+
+let
+ cfg = config.orbekk.valheim-server;
+ statePath = "/var/lib/${cfg.stateDir}";
+in
+{
+ options = {
+ orbekk.valheim-server = {
+ enable = lib.mkEnableOption "Enable valheim server";
+ programDir = lib.mkOption {
+ type = lib.types.str;
+ default = null;
+ };
+ stateDir = lib.mkOption {
+ type = lib.types.str;
+ default = "valheim";
+ };
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ systemd.services.valheim-server = {
+ description = "Valheim server";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network.target" ];
+ path = with pkgs; [ steam.run ];
+
+ serviceConfig = {
+ DynamicUser = true;
+ StateDirectory = cfg.stateDir;
+ };
+
+ environment = {
+ HOME = statePath;
+ };
+
+ script = ''
+ cd ${cfg.programDir}
+ export templdpath=$LD_LIBRARY_PATH
+ export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
+ export SteamAppId=892970
+ steam-run ./valheim_server.x86_64 -name "doomsday" -port 3400 -world "doomsday" -password "$(cat ${statePath}/password.txt)" -savedir ${statePath}
+ '';
+ };
+ };
+}