refactor: use simple instead of oneshot type for systemd
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-07-07 01:54:46 -04:00
parent 2a8eb46b03
commit 52242e645a
4 changed files with 33 additions and 22 deletions

View file

@ -21,7 +21,6 @@ in {
systemd = {
services.manage-subs = {
serviceConfig = {
Type = "oneshot";
User = mainUser;
Group = config.users.users.${mainUser}.group;
};

View file

@ -9,10 +9,10 @@ in {
../../modules/sshd.nix
../../modules/tailscale.nix
./modules/7-days-to-die.nix
./modules/binary-cache.nix
./modules/minecraft.nix
./modules/nfs.nix
./modules/steam-servers
];
vars = {

View file

@ -0,0 +1,32 @@
{pkgs, ...}: let
gamePath = "/var/lib/steam-servers/7-days-to-die";
relativeConfig = "serverconfig-7days.xml";
in {
systemd.extraConfig = "DefaultLimitNOFILE=10240";
# https://github.com/Krutonium/NewNix/blob/455aafc4caf553248ca228f844f021cecf494dc2/services/sevendaystodie.nix#L6
systemd.services."7-days-to-die" = {
wantedBy = ["multi-user.target"];
serviceConfig.User = "matt";
path = with pkgs; [
steam-run
steamcmd
];
script = ''
# Make sure gamePath exists and cd to it
mkdir -p ${gamePath}
cd ${gamePath}
# Install / Update server
steamcmd +force_install_dir ${gamePath} \
+login anonymous +app_update 294420 \
-beta latest_experimental \
+quit
# Launch server
steam-run ./startserver.sh -configfile=${relativeConfig}
'';
};
}

View file

@ -1,20 +0,0 @@
{pkgs, ...}: let
gamePath = "/var/lib/steam-servers/7-days-to-die";
in {
systemd.extraConfig = "DefaultLimitNOFILE=10240";
# https://github.com/Krutonium/NewNix/blob/455aafc4caf553248ca228f844f021cecf494dc2/services/sevendaystodie.nix#L6
systemd.services."7daystodie" = {
wantedBy = ["multi-user.target"];
serviceConfig.Type = "oneshot";
serviceConfig.User = "matt";
path = with pkgs; [steam-run steamcmd];
script = ''
mkdir -p ${gamePath}
cd ${gamePath}
steamcmd +force_install_dir ${gamePath} +login anonymous +app_update 294420 -beta latest_experimental +quit
steam-run ./startserver.sh -configfile=serverconfig-7days.xml
'';
};
}