Make arma3 module functional

Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
magic_rb 2024-04-12 18:22:33 +02:00
parent 08929724e8
commit 91eb3eab5c
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -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}
'';
};
};