Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 76b1875a4012
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 61a79754bd8e
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jan 10, 2020

  1. nixos/factorio: add extraSettings and package options

    Currently there is no way to set game settings, such as administrators.
    extraSettings allows users to override default game settings without
    adding many more settings.
    
    The package option allows users to use the experimental version, or
    override to a specific version with their own modified package.
    artemist committed Jan 10, 2020
    Copy the full SHA
    637d7a5 View commit details

Commits on Mar 30, 2020

  1. Merge pull request #77478 from artemist/nixos-factorio

    nixos/factorio: add extraSettings and package options
    veprbl authored Mar 30, 2020
    Copy the full SHA
    61a7975 View commit details
Showing with 21 additions and 5 deletions.
  1. +21 −5 nixos/modules/services/games/factorio.nix
26 changes: 21 additions & 5 deletions nixos/modules/services/games/factorio.nix
Original file line number Diff line number Diff line change
@@ -4,14 +4,13 @@ with lib;

let
cfg = config.services.factorio;
factorio = pkgs.factorio-headless;
name = "Factorio";
stateDir = "/var/lib/${cfg.stateDirName}";
mkSavePath = name: "${stateDir}/saves/${name}.zip";
configFile = pkgs.writeText "factorio.conf" ''
use-system-read-write-data-directories=true
[path]
read-data=${factorio}/share/factorio/data
read-data=${cfg.package}/share/factorio/data
write-data=${stateDir}
'';
serverSettings = {
@@ -37,7 +36,7 @@ let
only_admins_can_pause_the_game = true;
autosave_only_on_server = true;
admins = [];
};
} // cfg.extraSettings;
serverSettingsFile = pkgs.writeText "server-settings.json" (builtins.toJSON (filterAttrsRecursive (n: v: v != null) serverSettings));
modDir = pkgs.factorio-utils.mkModDirDrv cfg.mods;
in
@@ -115,6 +114,14 @@ in
Description of the game that will appear in the listing.
'';
};
extraSettings = mkOption {
type = types.attrs;
default = {};
example = { admins = [ "username" ];};
description = ''
Extra game configuration that will go into server-settings.json
'';
};
public = mkOption {
type = types.bool;
default = false;
@@ -136,6 +143,15 @@ in
Your factorio.com login credentials. Required for games with visibility public.
'';
};
package = mkOption {
type = types.package;
default = pkgs.factorio-headless;
defaultText = "pkgs.factorio-headless";
example = "pkgs.factorio-headless-experimental";
description = ''
Factorio version to use. This defaults to the stable channel.
'';
};
password = mkOption {
type = types.nullOr types.str;
default = null;
@@ -184,7 +200,7 @@ in
preStart = toString [
"test -e ${stateDir}/saves/${cfg.saveName}.zip"
"||"
"${factorio}/bin/factorio"
"${cfg.package}/bin/factorio"
"--config=${cfg.configFile}"
"--create=${mkSavePath cfg.saveName}"
(optionalString (cfg.mods != []) "--mod-directory=${modDir}")
@@ -197,7 +213,7 @@ in
StateDirectory = cfg.stateDirName;
UMask = "0007";
ExecStart = toString [
"${factorio}/bin/factorio"
"${cfg.package}/bin/factorio"
"--config=${cfg.configFile}"
"--port=${toString cfg.port}"
"--start-server=${mkSavePath cfg.saveName}"