From 91eb3eab5c60908e7a8657f0fdf3f2f1f1f24b52 Mon Sep 17 00:00:00 2001 From: magic_rb Date: Fri, 12 Apr 2024 18:22:33 +0200 Subject: [PATCH] Make arma3 module functional Signed-off-by: magic_rb --- nixos/systems/omen/arma3.nix | 100 ++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/nixos/systems/omen/arma3.nix b/nixos/systems/omen/arma3.nix index 007092c..617bc8d 100644 --- a/nixos/systems/omen/arma3.nix +++ b/nixos/systems/omen/arma3.nix @@ -1,8 +1,47 @@ { inputs', pkgs, + lib, ... -}: { +}: let + mods = [ + { + id = "463939057"; + name = "ACE"; + } + { + id = "2867537125"; + name = "Antistasi"; + } + { + id = "450814997"; + name = "CBA_A3"; + } + { + id = "843425103"; + name = "RHSAFRF"; + } + { + id = "843593391"; + name = "RHSGREF"; + } + { + id = "843632231"; + name = "RHSSAF"; + } + { + id = "843577117"; + name = "RHSUSAF"; + } + ]; + + inherit + (lib) + getExe + getExe' + concatMapStringsSep + ; +in { ucontainers."arma3" = { network = [ { @@ -16,9 +55,9 @@ ephemeral = true; bind = [ "/etc/resolv.conf" - "/var/lib/arma3/steam:/home/steam/Steam" - "/var/lib/arma3/Steam:/home/steam/.local/share/Steam" - "/var/lib/arma3/steamapps:/var/lib/steam" + "/var/lib/arma3/steam_library:/home/steam/Steam" + "/var/lib/arma3/steam:/home/steam/.local/share/Steam" + "/var/lib/arma3/game:/var/lib/game" "/tmp/arma-secret/:/secret" ]; }; @@ -28,13 +67,7 @@ inherit (inputs') nixpkgs; name = "arma3"; - config = let - inherit - (pkgs.lib) - getExe - getExe' - ; - in { + config = { dumb-init = { enable = true; type.services = {}; @@ -66,18 +99,39 @@ gid = 1001; }; + ## Steam doesn't allow me to download the mods as that account doesn't own Arma 3... + # ${concatMapStringsSep "\n" (mod: '' + # HOME=/home/steam USER=steam chpst -U steam:steam -u steam:steam ${getExe' pkgs.steamcmd "steamcmd"} \ + # +login "$(cat /secret/user | tr -d '\n ')" "$(cat /secret/password | tr -d '\n ')" \ + # +"workshop_download_item 107410 ${mod.id}" validate \ + # +quit + + # ln -sf /home/steam/Steam/steamapps/workshop/content/107410/${mod.id} /var/lib/game/mods/@${mod.name} + # '') + # mods} + init.services.steam-login = { enabled = true; script = pkgs.writeShellScript "steam-login-start" '' + set -e -o pipefail + mkdir -p /home/steam chown steam:steam -R /home/steam - chown steam:steam -R /var/lib/steam - HOME=/home/steam USER=steam chpst -U steam:steam -u steam:steam ${getExe pkgs.steamcmd} \ - +force_install_dir /var/lib/steam \ - +login "$(cat /secret/user)" "$(cat /secret/password)" \ + chown steam:steam -R /var/lib/game + HOME=/home/steam USER=steam chpst -U steam:steam -u steam:steam ${getExe' pkgs.steamcmd "steamcmd"} \ + +force_install_dir /var/lib/game \ + +login "$(cat /secret/user | tr -d '\n ')" "$(cat /secret/password | tr -d '\n ')" \ +app_update 233780 validate \ +quit + ${concatMapStringsSep "\n" ( + mod: '' + ln -sf /var/lib/game/mods/${mod.id} /var/lib/game/mods/@${mod.name} + '' + ) + mods} + + sv start arma3 exec sleep infinity ''; }; @@ -86,21 +140,17 @@ dependencies = [ "steam-login" ]; - enabled = true; + enabled = false; script = pkgs.writeShellScript "arma3-start" '' - sleep 15 - cd /var/lib/steam + cd /var/lib/game PATH=${pkgs.coreutils}/bin:$PATH LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:$PWD exec \ chpst -u steam:steam \ ${getExe' pkgs.glibc "ld.so"} ./arma3server_x64 \ -config=./server.cfg \ - -mod=./mods/@ACE \ - -mod=./mods/@Antistasi \ - -mod=./mods/@CBA_A3 \ - -mod=./mods/@RHSAFRF \ - -mod=./mods/@RHSGREF \ - -mod=./mods/@RHSSAF \ - -mod=./mods/@RHSUSAF + ${concatMapStringsSep " \\\n" ( + mod: "-mod=./mods/${mod.id}" + ) + mods} ''; }; };