From 8c36ae940bd216d03695b235a1e96dd8db96e801 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Tue, 24 Nov 2020 04:50:31 +0000 Subject: [PATCH] clouvider-lon01: add factorio server --- ops/nixos/clouvider-lon01/default.nix | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ops/nixos/clouvider-lon01/default.nix b/ops/nixos/clouvider-lon01/default.nix index 8db722fc4a..e700a3c71a 100644 --- a/ops/nixos/clouvider-lon01/default.nix +++ b/ops/nixos/clouvider-lon01/default.nix @@ -233,6 +233,29 @@ in { systemd.tmpfiles.rules = [ "d /run/minotarproxy 0700 minotarproxy - -" ]; + systemd.mounts = let + bindMount' = dir: { + unitConfig.RequiresMountsFor = dir; + options = "bind"; + what = "/persist${dir}"; + where = dir; + }; + bindMountSvc = dir: svc: (bindMount' dir) // { + bindsTo = [svc]; + partOf = [svc]; + }; + bindMountSvcDynamic = dir: svc: (bindMount' "/var/lib/private/${dir}") // { + requiredBy = [svc]; + before = [svc]; + wantedBy = ["multi-user.target"]; + }; + bindMount = dir: (bindMount' dir) // { + wantedBy = ["multi-user.target"]; + }; + in [ + (bindMountSvcDynamic "factorio" "factorio.service") + ]; + environment.etc."secrets/gitlab-runner-registration" = { text = '' @@ -262,5 +285,23 @@ in { nix.gc.automatic = false; + services.factorio = { + inherit (secrets.factorio) username token; + enable = true; + package = pkgs.factorio-headless-experimental; + saveName = "lukegb20201124"; + game-name = "Briefcase Full of Bees"; + extraSettings = { + admins = ["lukegb"]; + auto_pause = true; + only_admins_can_pause_the_game = false; + game_password = secrets.factorioServerPassword; + non_blocking_saving = true; + autosave_only_on_server = true; + autosave_interval = 5; + autosave_slots = 60; + }; + }; + system.stateVersion = "20.09"; }