summary refs log tree commit diff
path: root/nixos/modules/services/games
diff options
context:
space:
mode:
authorSvein Ove Aas <sveina@gmail.com>2022-04-29 14:27:06 +0100
committerSvein Ove Aas <sveina@gmail.com>2022-05-06 17:50:35 +0100
commitdcade93a2517b358936714a1c866ef7c10e49d4f (patch)
tree3dab485a5913f9da98a3092afd5d8bbd8dd0a7b5 /nixos/modules/services/games
parente10da1c7f542515b609f8dfbcf788f3d85b14936 (diff)
downloadnixpkgs-dcade93a2517b358936714a1c866ef7c10e49d4f.tar
nixpkgs-dcade93a2517b358936714a1c866ef7c10e49d4f.tar.gz
nixpkgs-dcade93a2517b358936714a1c866ef7c10e49d4f.tar.bz2
nixpkgs-dcade93a2517b358936714a1c866ef7c10e49d4f.tar.lz
nixpkgs-dcade93a2517b358936714a1c866ef7c10e49d4f.tar.xz
nixpkgs-dcade93a2517b358936714a1c866ef7c10e49d4f.tar.zst
nixpkgs-dcade93a2517b358936714a1c866ef7c10e49d4f.zip
factorio: Add loadLatestSave
Diffstat (limited to 'nixos/modules/services/games')
-rw-r--r--nixos/modules/services/games/factorio.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/nixos/modules/services/games/factorio.nix b/nixos/modules/services/games/factorio.nix
index ff73d7a46ed..bb6898a08c5 100644
--- a/nixos/modules/services/games/factorio.nix
+++ b/nixos/modules/services/games/factorio.nix
@@ -87,6 +87,18 @@ in
           a new map with default settings will be generated before starting the service.
         '';
       };
+      loadLatestSave = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Load the latest savegame on startup. This overrides saveName, in that the latest
+          save will always be used even if a saved game of the given name exists. It still
+          controls the 'canonical' name of the savegame.
+
+          Set this to true to have the server automatically reload a recent autosave after
+          a crash or desync.
+        '';
+      };
       # TODO Add more individual settings as nixos-options?
       # TODO XXX The server tries to copy a newly created config file over the old one
       #   on shutdown, but fails, because it's in the nix store. When is this needed?
@@ -250,8 +262,9 @@ in
           "--config=${cfg.configFile}"
           "--port=${toString cfg.port}"
           "--bind=${cfg.bind}"
-          "--start-server=${mkSavePath cfg.saveName}"
+          (optionalString (!cfg.loadLatestSave) "--start-server=${mkSavePath cfg.saveName}")
           "--server-settings=${serverSettingsFile}"
+          (optionalString cfg.loadLatestSave "--start-server-load-latest")
           (optionalString (cfg.mods != []) "--mod-directory=${modDir}")
           (optionalString (cfg.admins != []) "--server-adminlist=${serverAdminsFile}")
         ];