From 8361a16bfa1b5a4927ddc6b94a1ab000fec5d570 Mon Sep 17 00:00:00 2001 From: muItilingualism <58324365+muItilingualism@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:53:10 +0200 Subject: [PATCH 1/7] Add public flag option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Defaults to true when not set. This is apparently the default: "public 1 - Set the visibility of your server. 1 is default and will make the server visible in the browser. Set it to 0 to make the server invisible and only joinable via the ‘Join IP’-button." source: https://www.valheimgame.com/support/a-guide-to-dedicated-servers/ --- nixos-modules/valheim.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nixos-modules/valheim.nix b/nixos-modules/valheim.nix index 8958455..a481040 100644 --- a/nixos-modules/valheim.nix +++ b/nixos-modules/valheim.nix @@ -61,6 +61,16 @@ in { description = lib.mdDoc "Whether to open ports in the firewall."; }; + public = lib.mkOption { + type = lib.types.bool; + default = true; + description = lib.mdDoc '' + Toggles visibility on the Steam server & community lists. + When not set, defaults to true (visible). + Set to false to make the server private. + ''; + }; + password = lib.mkOption { type = lib.types.str; default = ""; @@ -223,8 +233,9 @@ in { ++ [ "-port \"${builtins.toString cfg.port}\"" "-password \"${cfg.password}\"" + "-public ${if cfg.public then "1" else "0"}" ] - ++ (lib.lists.optional cfg.crossplay "-crossplay")); + ++ (lib.lists.optional cfg.crossplay "-crossplay") }; }; }; From 0d3b29da772f74d8e26109140341a420a7f19f64 Mon Sep 17 00:00:00 2001 From: muItilingualism <58324365+muItilingualism@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:23:49 +0200 Subject: [PATCH 2/7] Add logFile flag --- nixos-modules/valheim.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nixos-modules/valheim.nix b/nixos-modules/valheim.nix index a481040..6a7a950 100644 --- a/nixos-modules/valheim.nix +++ b/nixos-modules/valheim.nix @@ -66,11 +66,25 @@ in { default = true; description = lib.mdDoc '' Toggles visibility on the Steam server & community lists. + When not set, defaults to true (visible). Set to false to make the server private. ''; }; + logFile = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + example = "/var/log/valheim-server.log"; + description = lib.mdDoc '' + The path where the server log file will be saved. + + When set, this will redirect all logs from stdout to the specified path. + This means that the logs will not be captured by systemd's journal. + Leave this option unset to keep console logging enabled. + ''; + }; + password = lib.mkOption { type = lib.types.str; default = ""; @@ -236,6 +250,7 @@ in { "-public ${if cfg.public then "1" else "0"}" ] ++ (lib.lists.optional cfg.crossplay "-crossplay") + ++ (lib.lists.optional (cfg.logFile != null) "-logFile \"${cfg.logFile}\"") }; }; }; From 3a68986d3f02145144bb5fe3b6d078d113c8257a Mon Sep 17 00:00:00 2001 From: muItilingualism <58324365+muItilingualism@users.noreply.github.com> Date: Wed, 31 Jul 2024 20:21:22 +0200 Subject: [PATCH 3/7] Add preset flag --- nixos-modules/valheim.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nixos-modules/valheim.nix b/nixos-modules/valheim.nix index 6a7a950..61e5ef8 100644 --- a/nixos-modules/valheim.nix +++ b/nixos-modules/valheim.nix @@ -85,6 +85,16 @@ in { ''; }; + preset = lib.mkOption { + type = lib.types.str; nullOr str; + default = null; + example = "hardcore"; + description = lib.mdDoc '' + The preset world modifier, valid options are + "easy", "hard", "hardcore", "casual", "hammer" and "immersive". + ''; + }; + password = lib.mkOption { type = lib.types.str; default = ""; @@ -251,6 +261,7 @@ in { ] ++ (lib.lists.optional cfg.crossplay "-crossplay") ++ (lib.lists.optional (cfg.logFile != null) "-logFile \"${cfg.logFile}\"") + ++ (lib.lists.optional (cfg.preset != null) "-preset \"${cfg.preset}\"") }; }; }; From 90b20c61a7e0e49975930b2a9d8a5d0995437c1a Mon Sep 17 00:00:00 2001 From: muItilingualism <58324365+muItilingualism@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:38:09 +0200 Subject: [PATCH 4/7] Fix missing parentheses --- nixos-modules/valheim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos-modules/valheim.nix b/nixos-modules/valheim.nix index 0aa18e2..5165ff2 100644 --- a/nixos-modules/valheim.nix +++ b/nixos-modules/valheim.nix @@ -315,7 +315,7 @@ in { ] ++ (lib.lists.optional cfg.crossplay "-crossplay") ++ (lib.lists.optional (cfg.logFile != null) "-logFile \"${cfg.logFile}\"") - ++ (lib.lists.optional (cfg.preset != null) "-preset \"${cfg.preset}\"") + ++ (lib.lists.optional (cfg.preset != null) "-preset \"${cfg.preset}\"")); }; }; }; From 5d086a3044c771f9b6e94468ed0e56a35466f700 Mon Sep 17 00:00:00 2001 From: muItilingualism <58324365+muItilingualism@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:28:34 +0200 Subject: [PATCH 5/7] Fix syntax error --- nixos-modules/valheim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos-modules/valheim.nix b/nixos-modules/valheim.nix index 5165ff2..c48f70a 100644 --- a/nixos-modules/valheim.nix +++ b/nixos-modules/valheim.nix @@ -86,7 +86,7 @@ in { }; preset = lib.mkOption { - type = lib.types.str; nullOr str; + type = lib.types; nullOr str; default = null; example = "hardcore"; description = lib.mdDoc '' From 42c41cd43d6b9ed75b80d39e4c3c7b6751db3883 Mon Sep 17 00:00:00 2001 From: muItilingualism <58324365+muItilingualism@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:30:00 +0200 Subject: [PATCH 6/7] Fix syntax error --- nixos-modules/valheim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos-modules/valheim.nix b/nixos-modules/valheim.nix index c48f70a..dd1459d 100644 --- a/nixos-modules/valheim.nix +++ b/nixos-modules/valheim.nix @@ -86,7 +86,7 @@ in { }; preset = lib.mkOption { - type = lib.types; nullOr str; + type = with lib.types; nullOr str; default = null; example = "hardcore"; description = lib.mdDoc '' From 3f2ff79baf7be3b773655bf1785bb28a6529af19 Mon Sep 17 00:00:00 2001 From: muItilingualism <58324365+muItilingualism@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:45:05 +0200 Subject: [PATCH 7/7] Add better logFile example and update doc --- nixos-modules/valheim.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos-modules/valheim.nix b/nixos-modules/valheim.nix index dd1459d..7e07419 100644 --- a/nixos-modules/valheim.nix +++ b/nixos-modules/valheim.nix @@ -75,13 +75,16 @@ in { logFile = lib.mkOption { type = with lib.types; nullOr str; default = null; - example = "/var/log/valheim-server.log"; + example = "/var/lib/valheim/log/valheim-server.log"; description = lib.mdDoc '' The path where the server log file will be saved. When set, this will redirect all logs from stdout to the specified path. This means that the logs will not be captured by systemd's journal. Leave this option unset to keep console logging enabled. + + Make sure the valheim user has write access to the specified directory, otherwise + the valheim service fail to start and exit. ''; };