Add and enable Satisfactory dedicated server
Add steamcmd to allowed unfree packages
This commit is contained in:
parent
10570b3613
commit
58291c04d2
|
@ -7,10 +7,9 @@
|
|||
./services/home-assistant.nix
|
||||
./services/minecraft.nix
|
||||
./services/nix-serve.nix
|
||||
# ./services/radicale.nix
|
||||
./services/satisfactory/default.nix
|
||||
./services/sshd.nix
|
||||
./services/syncthing.nix
|
||||
# ./services/znc.nix
|
||||
];
|
||||
boot.loader = {
|
||||
systemd-boot.enable = true;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
"steam"
|
||||
"steam-original"
|
||||
"steam-run"
|
||||
"steamcmd"
|
||||
];
|
||||
overlays = [ (final: prev: { inherit (inputs.plasma-manager.packages.${prev.system}) rc2nix; }) ];
|
||||
};
|
||||
|
|
9
system/services/satisfactory/default.nix
Normal file
9
system/services/satisfactory/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{ ... }:
|
||||
{
|
||||
imports = [ ./module.nix ];
|
||||
services.satisfactory-server = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
launchOptions = "-multihome=0.0.0.0";
|
||||
};
|
||||
}
|
87
system/services/satisfactory/module.nix
Normal file
87
system/services/satisfactory/module.nix
Normal file
|
@ -0,0 +1,87 @@
|
|||
# From: https://gitlab.kuca.cz/tom-kuca/nix-config/-/blob/a11e73470c4f9a151afe67c7fa3a960b838d0d98/modules/nixos/satisfactory.nix
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.satisfactory-server;
|
||||
in
|
||||
{
|
||||
options.services.satisfactory-server = {
|
||||
enable = lib.mkEnableOption "Satisfactory Dedicated Server";
|
||||
|
||||
steamcmdPackage = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = pkgs.steamcmd;
|
||||
defaultText = "pkgs.steamcmd";
|
||||
description = ''
|
||||
The package implementing SteamCMD
|
||||
'';
|
||||
};
|
||||
|
||||
dataDir = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Directory to store game server";
|
||||
default = "/var/lib/satisfactory";
|
||||
};
|
||||
|
||||
launchOptions = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Launch options to use.";
|
||||
default = "";
|
||||
};
|
||||
|
||||
openFirewall = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to open ports in the firewall for the server
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
systemd.services.satisfactory-server =
|
||||
let
|
||||
steamcmd = "${cfg.steamcmdPackage}/bin/steamcmd";
|
||||
steam-run = "${pkgs.steam-run}/bin/steam-run";
|
||||
in
|
||||
{
|
||||
description = "Satisfactory Dedicated Server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
TimeoutSec = "15min";
|
||||
ExecStart = "${steam-run} ${cfg.dataDir}/FactoryServer.sh ${cfg.launchOptions}";
|
||||
Restart = "always";
|
||||
User = "satisfactory";
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
};
|
||||
|
||||
preStart = ''
|
||||
${steamcmd} +force_install_dir "${cfg.dataDir}" +login anonymous +app_update 1690800 validate +quit
|
||||
'';
|
||||
};
|
||||
|
||||
users.users.satisfactory = {
|
||||
description = "Satisfactory server service user";
|
||||
home = cfg.dataDir;
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
group = "satisfactory";
|
||||
};
|
||||
users.groups.satisfactory = { };
|
||||
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedUDPPorts = [
|
||||
15777
|
||||
7777
|
||||
15000
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue