factorio-server-nix's Introduction
factorio-server-nix ------------------- A factorio server setup in Nix. Requirements ------------ - A NixOS install with Flakes enabled. Installation ------------ 1. Add the flake to your inputs. Example flake.nix: ------------------ inputs = { inputs.nixpkgs.url = "..."; inputs.factorio-server = { url = "github:emanueljg/factorio-server-nix"; # man --pager='less -j12 -p inputs.nixpkgs.follows' nix3-flake inputs.nixpkgs.follows = "nixpkgs"; }; }; ------------------ 2. Import the module and enable the service Example basic factorio-server.nix: ---------------------------- { pkgs, factorio-server, ... }: { imports = [ factorio-server.nixosModules.default ]; services.factorio-server = { enable = true; dataDir = "/var/lib/factorio-server" # Default. socketUser = "YOUR_USERNAME" # Highly recommended; see 5. Running commands. package = pkgs.factorio-headless # Default. Probably want to set a newer version though. openFirewall = true; # opens UDP port 34197 extraConfig = { # Merges with ./default-server-settings.json # max_players = 10; }; }; nixpkgs.config.allowUnfree = true; # factorio-headless is unfree } 3. Done! The factorio server will now start automatically on boot. 4. Custom map (Optional) The map is stored at "${dataDir}/map.zip". It is generated on startup if it does not exist. If you want your own custom map, you can either: - Customize map generation with factorio-server.mapCreationArgs. Just remember to remove the old map to generate a new one! - Copy over a pregenerated map to the data dir. 5. Running commands (Optional) The factorio server runs as a systemd service which listens for stdin through a socket using named pipes. In other words, you can write text to a file which then gets sent to the server's chat. You can do this manually (echo "hello world" > /tmp/factorio-server.stdin) but this is a bit cumbersome to write each time, so a simple shell wrapper is provided: $ factorio-cmd hello world $ journalctl -u factorio-server | grep 'hello world' nov 07 17:31:06 fenix factorio[2219352]: 2023-11-07 17:31:06 [CHAT] <server>: hello world If you have no perms for this command, this means the socket is not owned by you. You either need to: - Make yourself the socket owner by setting services.factorio-server.socketUser (see 2.) - Run the command as the service user: sudo -u factorio-server factorio-cmd hello world. This can of course be set as a shell alias too.
factorio-server-nix's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.