Initial flake commit

This commit is contained in:
2021-08-04 12:37:55 -07:00
parent 3b11040922
commit a5a6a02929
10 changed files with 122 additions and 46 deletions
+2
View File
@@ -43,6 +43,8 @@ with lib; {
./fudo/webmail.nix
./fudo/wireless-networks.nix
./fudo/games/valheim.nix
./informis/cl-gemini.nix
];
}
+5
View File
@@ -0,0 +1,5 @@
{ ... }:
{
imports = [ ./valheim.nix ];
}
+63
View File
@@ -0,0 +1,63 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.fudo.games.valheim;
in {
options.fudo.games.valheim = with types; {
enable = mkEnableOption "Enable dedicated Valheim server.";
state-directory = mkOption {
type = str;
description = "Directory at which to store Valheim state data.";
default = "/var/lib/valheim";
};
port = mkOption {
type = port;
description = "Port on which to listen for connections.";
default = 2456;
};
password = mkOption {
type = str;
description = "Password required by connecting users.";
};
};
config = mkIf cfg.enable {
users.users.valheim = {
home = cfg.state-directory;
createHome = true;
isSystemUser = true;
};
systemd.services.fudo-valheim = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStartPre = ''
[[ -d ${cfg.state-directory}/state ]] || mkdir ${cfg.state-directory}/state
${pkgs.steamcmd}/bin/steamcmd \
+login anonymous \
+force_install_dir ${cfg.state-directory}/state \
+app_update 896660 \
+quit
'';
ExecStart = ''
${pkgs.glibc}/lib/ld-linux-x86-64.so.2 ./valheim_server.x86_64 \
-name "CoCo Valheim" \
-port ${toString cfg.port} \
-world "Dedicated" \
-password ${cfg.password} \
-public 1
'';
Nice = -5;
Restart = "always";
User = "valheim";
StateDirectory = "${cfg.state-directory}/state";
WorkingDirectory = cfg.state-directory;
};
environment = { LD_LIBRARY_PATH = "linux64:${pkgs.glibc}/lib"; };
};
};
}