2024-03-23 08:31:33 +01:00
|
|
|
{
|
|
|
|
inputs',
|
|
|
|
pkgs,
|
2024-04-12 18:22:33 +02:00
|
|
|
lib,
|
2024-03-23 08:31:33 +01:00
|
|
|
...
|
2024-04-12 18:22:33 +02:00
|
|
|
}: 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 {
|
2024-04-13 19:38:04 +02:00
|
|
|
networking.nat.internalInterfaces = [
|
|
|
|
"arma3"
|
|
|
|
];
|
|
|
|
networking.nat = {
|
|
|
|
forwardPorts =
|
|
|
|
map (port: {
|
|
|
|
destination = "10.99.99.2:${toString port}";
|
|
|
|
proto = "udp";
|
|
|
|
sourcePort = port;
|
|
|
|
})
|
|
|
|
[
|
|
|
|
2302
|
|
|
|
2303
|
|
|
|
2304
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-03-23 08:31:33 +01:00
|
|
|
ucontainers."arma3" = {
|
|
|
|
network = [
|
|
|
|
{
|
|
|
|
hostAddress = "10.99.99.1/24";
|
|
|
|
guestAddress = "10.99.99.2/24";
|
|
|
|
hostInterface = "arma3";
|
|
|
|
guestInterface = "eth0";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
settings = {
|
|
|
|
ephemeral = true;
|
|
|
|
bind = [
|
|
|
|
"/etc/resolv.conf"
|
2024-04-12 18:22:33 +02:00
|
|
|
"/var/lib/arma3/steam_library:/home/steam/Steam"
|
|
|
|
"/var/lib/arma3/steam:/home/steam/.local/share/Steam"
|
|
|
|
"/var/lib/arma3/game:/var/lib/game"
|
2024-04-13 19:38:04 +02:00
|
|
|
"/var/lib/arma3/secret:/secret"
|
2024-03-23 08:31:33 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
path =
|
|
|
|
(inputs'.nixng.nglib.makeSystem {
|
|
|
|
inherit (pkgs.stdenv) system;
|
|
|
|
inherit (inputs') nixpkgs;
|
|
|
|
name = "arma3";
|
|
|
|
|
2024-04-12 18:22:33 +02:00
|
|
|
config = {
|
2024-03-23 08:31:33 +01:00
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
nixpkgs.pkgs = pkgs;
|
|
|
|
|
|
|
|
init.services.network = {
|
|
|
|
enabled = true;
|
|
|
|
script = pkgs.writeShellScript "network-start" ''
|
|
|
|
ip addr add "10.99.99.2/24" dev "eth0"
|
|
|
|
ip link set "eth0" up
|
|
|
|
ip route add "10.99.99.0/24" dev "eth0"
|
|
|
|
ip route add default via "10.99.99.1" dev "eth0"
|
|
|
|
|
|
|
|
touch /etc/hosts
|
|
|
|
|
|
|
|
exec sleep infinity
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users."steam" = {
|
|
|
|
uid = 1001;
|
|
|
|
home = "/home/steam";
|
|
|
|
group = "steam";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups."steam" = {
|
|
|
|
gid = 1001;
|
|
|
|
};
|
|
|
|
|
2024-04-12 18:22:33 +02:00
|
|
|
## 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}
|
|
|
|
|
2024-03-23 08:31:33 +01:00
|
|
|
init.services.steam-login = {
|
|
|
|
enabled = true;
|
|
|
|
script = pkgs.writeShellScript "steam-login-start" ''
|
2024-04-12 18:22:33 +02:00
|
|
|
set -e -o pipefail
|
|
|
|
|
2024-03-23 08:31:33 +01:00
|
|
|
mkdir -p /home/steam
|
|
|
|
chown steam:steam -R /home/steam
|
2024-04-12 18:22:33 +02:00
|
|
|
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 ')" \
|
2024-03-23 08:31:33 +01:00
|
|
|
+app_update 233780 validate \
|
|
|
|
+quit
|
|
|
|
|
2024-04-12 18:22:33 +02:00
|
|
|
${concatMapStringsSep "\n" (
|
|
|
|
mod: ''
|
|
|
|
ln -sf /var/lib/game/mods/${mod.id} /var/lib/game/mods/@${mod.name}
|
|
|
|
''
|
|
|
|
)
|
|
|
|
mods}
|
|
|
|
|
|
|
|
sv start arma3
|
2024-03-23 08:31:33 +01:00
|
|
|
exec sleep infinity
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
init.services.arma3 = {
|
|
|
|
dependencies = [
|
|
|
|
"steam-login"
|
|
|
|
];
|
2024-04-12 18:22:33 +02:00
|
|
|
enabled = false;
|
2024-03-23 08:31:33 +01:00
|
|
|
script = pkgs.writeShellScript "arma3-start" ''
|
2024-04-12 18:22:33 +02:00
|
|
|
cd /var/lib/game
|
2024-03-23 08:31:33 +01:00
|
|
|
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 \
|
2024-04-12 18:22:33 +02:00
|
|
|
${concatMapStringsSep " \\\n" (
|
|
|
|
mod: "-mod=./mods/${mod.id}"
|
|
|
|
)
|
|
|
|
mods}
|
2024-03-23 08:31:33 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.config
|
|
|
|
.system
|
|
|
|
.build
|
|
|
|
.toplevel;
|
|
|
|
};
|
|
|
|
}
|