summary refs log tree commit diff
path: root/nixos/modules/services/games
diff options
context:
space:
mode:
authorShaun Sharples <shaun.sharples@gmail.com>2017-01-22 17:51:11 +0200
committerRobin Gloster <mail@glob.in>2017-01-25 21:39:37 +0100
commit7f358917ee988afd45248563f6f74a6ef7b2a5fe (patch)
tree3722312e631c46a0adf05ca946ec12f32fcdb892 /nixos/modules/services/games
parentcde8e89a2e5e0ce5706bbd86df359938be083fa3 (diff)
downloadnixpkgs-7f358917ee988afd45248563f6f74a6ef7b2a5fe.tar
nixpkgs-7f358917ee988afd45248563f6f74a6ef7b2a5fe.tar.gz
nixpkgs-7f358917ee988afd45248563f6f74a6ef7b2a5fe.tar.bz2
nixpkgs-7f358917ee988afd45248563f6f74a6ef7b2a5fe.tar.lz
nixpkgs-7f358917ee988afd45248563f6f74a6ef7b2a5fe.tar.xz
nixpkgs-7f358917ee988afd45248563f6f74a6ef7b2a5fe.tar.zst
nixpkgs-7f358917ee988afd45248563f6f74a6ef7b2a5fe.zip
factorio: settings moved from command-line options to server-settings.json
Diffstat (limited to 'nixos/modules/services/games')
-rw-r--r--nixos/modules/services/games/factorio.nix86
1 files changed, 84 insertions, 2 deletions
diff --git a/nixos/modules/services/games/factorio.nix b/nixos/modules/services/games/factorio.nix
index 0369752997a..68ebcf35f6b 100644
--- a/nixos/modules/services/games/factorio.nix
+++ b/nixos/modules/services/games/factorio.nix
@@ -14,6 +14,31 @@ let
     read-data=${factorio}/share/factorio/data
     write-data=${stateDir}
   '';
+  serverSettings = {
+    name = cfg.game-name;
+    description = cfg.description;
+    visibility = {
+      public = cfg.public;
+      lan = cfg.lan;
+    };
+    username = cfg.username;
+    password = cfg.password;
+    token = cfg.token;
+    game_password = cfg.game-password;
+    require_user_verification = true;
+    max_upload_in_kilobytes_per_second = 0;
+    minimum_latency_in_ticks = 0;
+    ignore_player_limit_for_returning_players = false;
+    allow_commands = "admins-only";
+    autosave_interval = cfg.autosave-interval;
+    autosave_slots = 5;
+    afk_autokick_interval = 0;
+    auto_pause = true;
+    only_admins_can_pause_the_game = true;
+    autosave_only_on_server = true;
+    admins = [];
+  };
+  serverSettingsFile = pkgs.writeText "server-settings.json" (builtins.toJSON (filterAttrsRecursive (n: v: v != null) serverSettings));
   modDir = pkgs.factorio-mkModDirDrv cfg.mods;
 in
 {
@@ -67,12 +92,68 @@ in
           derivations via nixos-channel. Until then, this is for experts only.
         '';
       };
+      game-name = mkOption {
+        type = types.nullOr types.string;
+        default = "Factorio Game";
+        description = ''
+          Name of the game as it will appear in the game listing.
+        '';
+      };
+      description = mkOption {
+        type = types.nullOr types.string;
+        default = "";
+        description = ''
+          Description of the game that will appear in the listing.
+        '';
+      };
+      public = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Game will be published on the official Factorio matching server.
+        '';
+      };
+      lan = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Game will be broadcast on LAN.
+        '';
+      };
+      username = mkOption {
+        type = types.nullOr types.string;
+        default = null;
+        description = ''
+          Your factorio.com login credentials. Required for games with visibility public.
+        '';
+      };
+      password = mkOption {
+        type = types.nullOr types.string;
+        default = null;
+        description = ''
+          Your factorio.com login credentials. Required for games with visibility public.
+        '';
+      };
+      token = mkOption {
+        type = types.nullOr types.string;
+        default = null;
+        description = ''
+          Authentication token. May be used instead of 'password' above.
+        '';
+      };
+      game-password = mkOption {
+        type = types.nullOr types.string;
+        default = null;
+        description = ''
+          Game password.
+        '';
+      };
       autosave-interval = mkOption {
         type = types.nullOr types.int;
         default = null;
-        example = 2;
+        example = 10;
         description = ''
-          The time, in minutes, between autosaves.
+          Autosave interval in minutes.
         '';
       };
     };
@@ -120,6 +201,7 @@ in
           "--config=${cfg.configFile}"
           "--port=${toString cfg.port}"
           "--start-server=${mkSavePath cfg.saveName}"
+          "--server-settings=${serverSettingsFile}"
           (optionalString (cfg.mods != []) "--mod-directory=${modDir}")
           (optionalString (cfg.autosave-interval != null) "--autosave-interval ${toString cfg.autosave-interval}")
         ];