Factorio: Difference between revisions
imported>Mac-chaffee mention IPv6 support |
m →Mods: : Update upstream link. |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[https:// | <strong>[https://www.factorio.com Factorio]</strong> is a video game created by [https://www.factorio.com/game/about Wube Software]. Factorio has a multiplayer mode that requires a dedicated server, which is available on Nixpkgs and can be installed on NixOS. | ||
== Installation == | |||
{{Unfree}} | |||
To install the Factorio server, add | To install the Factorio server, add the following to your [[Overview_of_the_NixOS_Linux_distribution#Declarative_Configuration|NixOS configuration]]: | ||
< | {{file|configuration.nix|nix| | ||
environment.systemPackages = | <nowiki> | ||
{ | |||
]; | environment.systemPackages = [ pkgs.factorio-headless ]; | ||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ | |||
nixpkgs.config. | "factorio-headless" | ||
</ | ]; | ||
} | |||
</nowiki> | |||
}} | |||
{{Evaluate}} | |||
It | It is important to only install <code>factorio-headless</code> instead of <code>factorio</code> because the headless version is a redistributable download that does not require login credentials. | ||
== Configuration == | == Configuration == | ||
Here is a minimum viable configuration for the Factorio server | Here is a minimum viable configuration for the Factorio server: | ||
< | {{file|configuration.nix|nix| | ||
services.factorio = { | <nowiki> | ||
{ | |||
services.factorio = { | |||
}; | enable = true; | ||
</ | openFirewall = true; | ||
}; | |||
} | |||
</nowiki> | |||
}} | |||
This will run a | This will run a unprotected server that binds to the <code>0.0.0.0</code> local IP address and uses the default UDP port of <code>34197</code>, with an auto-generated save file. Factorio servers support IPv6 by setting <code>bind = "[::]";</code>. All default settings can be seen here: {{nixos:option|services.factorio.*}} | ||
== Mods == | === Mods === | ||
The NixOS module for Factorio supports [https://wiki.factorio.com/Modding | The NixOS module for Factorio supports [https://wiki.factorio.com/Modding third-party modifications], or <i>mods</i>, which are just compressed archives with extra game content. While technically you can create a full derivation for mods, in practice this can get complicated, especially since authentication is required to download mods from the official mod site. | ||
Instead, you can download the mods you need | Instead, you can download the mods you need imperatively from https://mods.factorio.com/, place them in a folder such as <code>/etc/nixos/factorio-mods</code>, and put this code in your [[Overview_of_the_NixOS_Linux_distribution#Declarative_Configuration|NixOS configuration]]: | ||
< | {{file|configuration.nix|nix| | ||
services.factorio = { | <nowiki> | ||
{ | |||
services.factorio = { | |||
mods = | |||
let | |||
modDir = ./factorio-mods; | |||
modList = lib.pipe modDir [ | |||
builtins.readDir | |||
(lib.filterAttrs (k: v: v == "regular")) | |||
(lib.mapAttrsToList (k: v: k)) | |||
(builtins.filter (lib.hasSuffix ".zip")) | |||
]; | |||
validPath = modFileName: | |||
builtins.path { | |||
path = modDir + "/${modFileName}"; | |||
name = lib.strings.sanitizeDerivationName modFileName; | |||
}; | |||
modToDrv = modFileName: | |||
pkgs.runCommand "copy-factorio-mods" {} '' | |||
mkdir $out | |||
}; | ln -s '${validPath modFileName}' $out/'${modFileName}' | ||
</ | '' | ||
// { deps = []; }; | |||
in | |||
builtins.map modToDrv modList; | |||
}; | |||
} | |||
</nowiki> | |||
}} | |||
This code was developed by [https://github.com/nicball/nuc-nixos-configuration/blob/fccfa8441cba60c835aa2eb4238ae6f53bb781bb/factorio.nix#L16-L37 nicball]. | |||
== See also == | |||
[ | * [https://wiki.factorio.com/Multiplayer The Factorio wiki page on Multiplayer] | ||
[[Category: | |||
[[Category: | [[Category:Gaming]] | ||
[[Category:Server]] |