3.7 KiB
3.7 KiB
Add a SteamCMD server
1. Configure the generic SteamCMD module
- Create or update
configs/nixos/modules/services/steamcmd.nix. - Define
modules.services.steamcmd.enable. - Create the
steamcmdservice user. - Configure the shared SteamCMD data directory.
- Add options for one Steam app service.
- Run SteamCMD before the game service starts.
- Update the Steam app on each service restart.
- Add a restart timer with default settings.
- Add an option that overrides the restart command.
- Open declared in-machine firewall ports.
2. Configure the game service module
- Create or update
configs/nixos/modules/services/<game>.nix. - Define
modules.services.<game>.enable. - Add the Steam app ID for the dedicated server.
- Add runtime packages that the server binary needs.
- Add
serverNamefor the service identity. - Use
serverNameas the default world or save name. - Add a game-specific world or save option when the game supports it.
- Add guest-internal paths for server files and durable state.
- Add options for required ports.
- Add options for required secret files or values.
- Map the game options to
modules.services.steamcmd. - Configure the game service command.
- Pass secrets to the service without embedding secret values in Nix.
- Open the required in-machine firewall ports.
3. Configure the guest module
- Create or update
configs/nixos/guests/<game>.nix. - Define
guests.<game>options for host-level wiring. - Add
serverName. - Pass
serverNametomodules.services.<game>insideinterior. - Add host path options for SteamCMD data, server files, and durable state.
- Use names such as
steamcmdPath,serverPath, andstatePath. - Mount each host path into the guest.
- Mount sops-backed secret files read-only into the guest.
- Pass guest paths for secret files to
modules.services.<game>. - Set guest resource limits.
- Keep VLAN placement and address wiring in the guest or host configuration.
4. Add host storage
- Choose a host path for SteamCMD data.
- Choose a host path for downloaded server files.
- Choose a host path for world data, saves, and generated config.
- Configure those paths through
guests.<game>.
5. Add secrets
- Add a sops secret for each durable server secret.
- Configure the guest option that names each sops secret.
- Do not put passwords or tokens in Nix strings.
- Do not pass passwords or tokens as process arguments.
6. Configure networking
- Keep game port knowledge in
modules.services.<game>. - Open game ports from
modules.services.<game>. - Configure guest VLAN placement from the guest or host configuration.
- Add a DHCP reservation before you commit a stable guest address.
- Forward public ports to the guest address when the server needs public access.
7. Enable the guest on the target host
- Set
guests.<game>.enable = true. - Set
guests.<game>.serverNameto the server identity. - Set the host paths for SteamCMD data, server files, and durable state.
- Set the secret names for the server.
- Set the guest network options required by the host.
8. Deploy the host
- Run
deploy-to <host>from a clean checkout. - Check
container@<game>.serviceon the host. - Enter the guest with
nixos-container root-login <game>. - Check the SteamCMD update service.
- Check the game service with
systemctl status <unit>. - Follow logs with
journalctl -u <unit> -f.
9. Validate the server
- Confirm the guest address with
machinectl status <game>. - Connect from the LAN before you add public forwarding.
- Restart the game service.
- Confirm that the restart updates the Steam app.
- Confirm that the restart timer uses the expected command.
- Confirm that durable state lands in the mounted state path.