Skip to content

Commit

Permalink
feat: update + new module options
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston committed Sep 14, 2024
1 parent 6982368 commit 1b2cb3e
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 71 deletions.
153 changes: 128 additions & 25 deletions docs/nixos-options.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## services\.satisfactory\.enable



Whether to enable Satisfactory Dedicated Server\.


Expand Down Expand Up @@ -39,10 +37,36 @@ package



## services\.satisfactory\.beaconPort
## services\.satisfactory\.openFirewall



Override the Beacon Port the server uses\. As of Update 6, this port can be set freely\.
If this port is already in use, the server will step up to the next port until an available one is found\.
Whether to open the ports in the firewall\.



*Type:*
boolean



*Default:*
` false `



*Example:*
` true `



## services\.satisfactory\.port



Override the Game Port the server uses\.
This is the primary port used to communicate game telemetry with the client\.
If it is already in use, the server will step up to the next port until an available one is found\.



Expand All @@ -52,82 +76,161 @@ If this port is already in use, the server will step up to the next port until a


*Default:*
` 15000 `
` 7777 `



## services\.satisfactory\.listenAddress
## services\.satisfactory\.settings



Bind the server process to a specific IP address rather than all available interfaces\.
Satisfactory engine \& game settings\.



*Type:*
string
submodule



*Default:*
` "0.0.0.0" `
` { } `



## services\.satisfactory\.openFirewall
## services\.satisfactory\.settings\.autosaveNumber



Whether to open the ports in the firewall\.
Specifies the number of rotating autosaves to keep\.



*Type:*
boolean
positive integer, meaning >0



*Default:*
` false `
` 5 `



## services\.satisfactory\.port
## services\.satisfactory\.settings\.clientTimeout



Override the Game Port the server uses\.
This is the primary port used to communicate game telemetry with the client\.
If it is already in use, the server will step up to the next port until an available one is found\.
Specifies the number of rotating autosaves to keep\.



*Type:*
16 bit unsigned integer; between 0 and 65535 (both inclusive)
positive integer, meaning >0



*Default:*
` 7777 `
` 5 `



## services\.satisfactory\.serverQueryPort
## services\.satisfactory\.settings\.maxObjects



Override the Query Port the server uses\.
This is the port specified in the Server Manager in the client UI to establish a server connection\.
Specifies the maximum object limit for the server\.



*Type:*
16 bit unsigned integer; between 0 and 65535 (both inclusive)
positive integer, meaning >0



*Default:*
` 2162688 `



## services\.satisfactory\.settings\.maxPlayers



Specifies the maximum number of players to allow on the server\.



*Type:*
positive integer, meaning >0



*Default:*
` 4 `



## services\.satisfactory\.settings\.maxTickrate



Specifies the maximum tick rate for the server\.



*Type:*
positive integer, meaning >0



*Default:*
` 15777 `
` 30 `



## services\.satisfactory\.settings\.seasonalEvents



Whether to enable seasonal events, such as FICSMAS\.



*Type:*
boolean



*Default:*
` true `



*Example:*
` true `



## services\.satisfactory\.settings\.streaming



Whether to enable asset streaming\.



*Type:*
boolean



*Default:*
` true `



*Example:*
` true `



Expand Down
112 changes: 69 additions & 43 deletions modules/satisfactory.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,6 @@ in
description = "User to run the server as.";
};

listenAddress = lib.mkOption {
type = lib.types.str;
default = "0.0.0.0";
description = ''
Bind the server process to a specific IP address rather than all available interfaces.
'';
};

serverQueryPort = lib.mkOption {
type = lib.types.port;
default = 15777;
description = ''
Override the Query Port the server uses.
This is the port specified in the Server Manager in the client UI to establish a server connection.
'';
};

beaconPort = lib.mkOption {
type = lib.types.port;
default = 15000;
description = ''
Override the Beacon Port the server uses. As of Update 6, this port can be set freely.
If this port is already in use, the server will step up to the next port until an available one is found.
'';
};

port = lib.mkOption {
type = lib.types.port;
default = 7777;
Expand All @@ -62,11 +36,49 @@ in
'';
};

openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
openFirewall = lib.mkEnableOption "" // {
description = "Whether to open the ports in the firewall.";
};

settings = lib.mkOption {
description = "Satisfactory engine & game settings.";
default = { };
type = lib.types.submodule {
options = {
autosaveNumber = lib.mkOption {
description = "Specifies the number of rotating autosaves to keep.";
type = lib.types.ints.positive;
default = 5;
};
clientTimeout = lib.mkOption {
description = "Specifies the number of rotating autosaves to keep.";
type = lib.types.ints.positive;
default = 5;
};
streaming = lib.mkEnableOption "asset streaming" // {
default = true;
};
maxObjects = lib.mkOption {
description = "Specifies the maximum object limit for the server.";
type = lib.types.ints.positive;
default = 2162688;
};
maxTickrate = lib.mkOption {
description = "Specifies the maximum tick rate for the server.";
type = lib.types.ints.positive;
default = 30;
};
maxPlayers = lib.mkOption {
description = "Specifies the maximum number of players to allow on the server.";
type = lib.types.ints.positive;
default = 4;
};
seasonalEvents = lib.mkEnableOption "seasonal events, such as FICSMAS" // {
default = true;
};
};
};
};
};

config = lib.mkIf cfg.enable {
Expand All @@ -78,10 +90,10 @@ in
users = {
groups.${cfg.user} = { };
users.${cfg.user} = {
isSystemUser = true;
createHome = lib.mkDefault true;
group = cfg.user;
home = cfg.stateDir;
createHome = true;
isSystemUser = lib.mkDefault true;
};
};

Expand All @@ -98,22 +110,36 @@ in
serviceConfig = {
Type = "exec";
User = cfg.user;
ExecStart = lib.strings.concatStringsSep " " [
"${lib.getExe cfg.package}"
"-multihome=${cfg.listenAddress}"
"-QueryPort=${builtins.toString cfg.serverQueryPort}"
"-BeaconPort=${builtins.toString cfg.beaconPort}"
"-GamePort=${builtins.toString cfg.port}"
];
ExecStart = lib.escapeShellArgs (
[
(lib.getExe cfg.package)
"-ini:Engine:[/Script/Engine.Engine]:NetClientTicksPerSecond=${toString cfg.settings.maxTickrate}"
"-ini:Engine:[/Script/Engine.GarbageCollectionSettings]:gc.MaxObjectsInEditor=${toString cfg.settings.maxObjects}"
"-ini:Engine:[/Script/FactoryGame.FGSaveSession]:mNumRotatingAutosaves=${toString cfg.settings.autosaveNumber}"
"-ini:Engine:[/Script/OnlineSubsystemUtils.IpNetDriver]:ConnectionTimeout=${toString cfg.settings.clientTimeout}"
"-ini:Engine:[/Script/OnlineSubsystemUtils.IpNetDriver]:InitialConnectTimeout=${toString cfg.settings.clientTimeout}"
"-ini:Engine:[/Script/OnlineSubsystemUtils.IpNetDriver]:LanServerMaxTickRate=${toString cfg.settings.maxTickrate}"
"-ini:Engine:[/Script/OnlineSubsystemUtils.IpNetDriver]:NetServerMaxTickRate=${toString cfg.settings.maxTickrate}"
"-ini:Engine:[ConsoleVariables]:wp.Runtime.EnableServerStreaming=${
if cfg.settings.streaming then "1" else "0"
}"
"-ini:Engine:[Core.Log]:LogNet=Error"
"-ini:Engine:[Core.Log]:LogNetTraffic=Warning"
"-ini:Game:[/Script/Engine.GameSession]:ConnectionTimeout=${toString cfg.settings.clientTimeout}"
"-ini:Game:[/Script/Engine.GameSession]:InitialConnectTimeout=${toString cfg.settings.clientTimeout}"
"-ini:Game:[/Script/Engine.GameSession]:MaxPlayers=${toString cfg.settings.maxPlayers}"
"-ini:GameUserSettings:[/Script/Engine.GameSession]:MaxPlayers=${toString cfg.settings.maxPlayers}"
"-Port=${builtins.toString cfg.port}"
"-DisablePacketRouting"
]
++ lib.optionals (!cfg.settings.seasonalEvents) [ "-DisableSeasonalEvents" ]
);
};
};

networking.firewall = lib.mkIf cfg.openFirewall {
allowedUDPPorts = [
cfg.serverQueryPort
cfg.beaconPort
cfg.port
];
allowedTCPPorts = [ cfg.port ];
allowedUDPPorts = [ cfg.port ];
};
};
}
6 changes: 3 additions & 3 deletions pkgs/satisfactory-server/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ let
in
stdenvNoCC.mkDerivation (finalAttrs: {
name = "satisfactory-server";
version = "0.218.21";
version = "15677691";

src = fetchSteam {
inherit (finalAttrs) name;
appId = "1690800";
depotId = "1690802";
manifestId = "1910179703516567959";
hash = "sha256-TxPegZFAwiAzuHgw9xLGr5sAP7KAVMMfPFYL7TRX1O0=";
manifestId = "5721043551877492542";
hash = "sha256-5/Xyaxg9tMFnr0hcfQLVQWu+BK5zjV3I8qcAaK8VkZw=";
};

dontBuild = true;
Expand Down

0 comments on commit 1b2cb3e

Please sign in to comment.