193 lines
6.0 KiB
Nix
193 lines
6.0 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
let
|
|
mods = let
|
|
modFromFile = { file, deps, ... }:
|
|
let basename = baseNameOf file;
|
|
in pkgs.stdenv.mkDerivation {
|
|
name = basename;
|
|
src = file;
|
|
phases = [ "installPhase" ];
|
|
installPhase = ''
|
|
mkdir $out
|
|
cp $src $out/${basename}
|
|
'';
|
|
inherit deps;
|
|
};
|
|
modzip = { filename, deps ? [ ], ... }:
|
|
modFromFile {
|
|
file = (../../../static/factorio + "/${filename}");
|
|
inherit deps;
|
|
};
|
|
in rec {
|
|
advanced-autonomous-industries =
|
|
modzip { filename = "aai-industry_0.5.19.zip"; };
|
|
alien-biomes = modzip { filename = "alien-biomes_0.6.7.zip"; };
|
|
aircraft = modzip { filename = "Aircraft_1.8.4.zip"; };
|
|
armored-biters = modzip { filename = "ArmouredBiters_1.1.6.zip"; };
|
|
big-data-string = modzip { filename = "big-data-string_1.0.1.zip"; };
|
|
bobs-enemies = modzip { filename = "bobenemies_1.1.5.zip"; };
|
|
bottleneck = modzip { filename = "Bottleneck_0.11.7.zip"; };
|
|
bullet-trails = modzip { filename = "bullet-trails_0.6.2.zip"; };
|
|
even-distribution = modzip { filename = "even-distribution_1.0.10.zip"; };
|
|
flib = modzip { filename = "flib_0.11.2.zip"; };
|
|
flow-control = modzip { filename = "Flow Control_3.1.3.zip"; };
|
|
fluid-must-flow = modzip { filename = "FluidMustFlow_1.3.1.zip"; };
|
|
gdiw = modzip { filename = "GDIW_1.1.0.zip"; };
|
|
hovercrafts = modzip { filename = "Hovercrafts_1.2.2.zip"; };
|
|
industrial-revolution-2 =
|
|
modzip { filename = "IndustrialRevolution_2.3.2.zip"; };
|
|
krastorio2 = modzip {
|
|
filename = "Krastorio2_1.3.6.zip";
|
|
deps = [ krastorio2-assets flib ];
|
|
};
|
|
krastorio2-assets = modzip { filename = "Krastorio2Assets_1.2.0.zip"; };
|
|
larger-lamps = modzip { filename = "DeadlockLargerLamp_1.5.0.zip"; };
|
|
miniloader = modzip { filename = "miniloader_1.15.6.zip"; };
|
|
planet-imaging-satellite =
|
|
modzip { filename = "planetImagingSatellite_1.0.3.zip"; };
|
|
rampant = modzip { filename = "Rampant_3.1.2.zip"; };
|
|
recipe-book = modzip { filename = "RecipeBook_3.4.5.zip"; };
|
|
space-exploration = modzip { filename = "space-exploration_0.6.89.zip"; };
|
|
stackers = modzip { filename = "deadlock-beltboxes-loaders_2.4.2.zip"; };
|
|
trees = modzip {
|
|
filename = "Trees_4.5.1.zip";
|
|
deps = [ big-data-string ];
|
|
};
|
|
vehicle-snap = modzip { filename = "VehicleSnap_1.18.4.zip"; };
|
|
};
|
|
|
|
worldGenSeed = 5298;
|
|
|
|
mapGenSettings = {
|
|
autoplace_controls = {
|
|
coal = {
|
|
size = 4;
|
|
richness = "high";
|
|
};
|
|
copper-ore = {
|
|
size = 10;
|
|
richness = "high";
|
|
};
|
|
crude-oil = {
|
|
size = 10;
|
|
richness = "high";
|
|
};
|
|
iron-ore = {
|
|
size = 10;
|
|
richness = "high";
|
|
};
|
|
stone = {
|
|
size = 4;
|
|
richness = "high";
|
|
};
|
|
uranium-ore = {
|
|
size = 4;
|
|
richness = "high";
|
|
};
|
|
};
|
|
seed = (toString worldGenSeed);
|
|
};
|
|
|
|
stateDirName = "citadel";
|
|
|
|
in {
|
|
config = {
|
|
services.factorio = {
|
|
enable = true;
|
|
|
|
# 'factorio' points to an old game
|
|
inherit stateDirName;
|
|
|
|
package = pkgs.factorio-headless-experimental.override {
|
|
username = "fudoniten";
|
|
token = lib.removeSuffix "\n" (readFile
|
|
config.fudo.secrets.files.blobs."factorio-token-fudoniten.txt");
|
|
};
|
|
|
|
public = false;
|
|
port = 34197;
|
|
lan = true;
|
|
game-name = "Fudo Factorio";
|
|
description = "Fudo Factorio Server";
|
|
admins = [ "fudoniten" "Arkayuu" ];
|
|
openFirewall = true;
|
|
autosave-interval = 30;
|
|
loadLatestSave = true;
|
|
mods = with mods; [
|
|
alien-biomes
|
|
# aircraft
|
|
#armored-biters
|
|
bottleneck
|
|
bullet-trails
|
|
fluid-must-flow
|
|
#krastorio2
|
|
# industrial-revolution-2
|
|
larger-lamps
|
|
stackers
|
|
trees
|
|
];
|
|
};
|
|
|
|
fileSystems = {
|
|
"/var/lib/private/${stateDirName}" = {
|
|
device = "/state/services/factorio/${stateDirName}";
|
|
options = [ "bind" ];
|
|
};
|
|
};
|
|
|
|
systemd.services.factorio = let
|
|
cfg = config.services.factorio;
|
|
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 = cfg.requireUserVerification;
|
|
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 = false;
|
|
autosave_only_on_server = true;
|
|
non_blocking_saving = cfg.nonBlockingSaving;
|
|
} // cfg.extraSettings;
|
|
in {
|
|
serviceConfig.ExecStart = mkForce (toString [
|
|
"${cfg.package}/bin/factorio"
|
|
"--config=${cfg.configFile}"
|
|
"--port=${toString cfg.port}"
|
|
"--bind=${toString cfg.bind}"
|
|
(optionalString (!cfg.loadLatestSave)
|
|
"--start-server=/var/lib/${cfg.stateDirName}/saves/${cfg.saveName}.zip")
|
|
"--server-settings=${
|
|
pkgs.writeText "factorio-server-settings.json" (builtins.toJSON
|
|
(filterAttrsRecursive (n: v: v != null) serverSettings))
|
|
}"
|
|
(optionalString cfg.loadLatestSave "--start-server-load-latest")
|
|
(optionalString (cfg.mods != [ ])
|
|
"--mod-directory=${pkgs.factorio-utils.mkModDirDrv cfg.mods null}")
|
|
(optionalString (cfg.admins != [ ]) "--server-adminlist=${
|
|
pkgs.writeText "factorio-server-adminlist.json"
|
|
(builtins.toJSON cfg.admins)
|
|
}")
|
|
"--map-gen-settings=${
|
|
pkgs.writeText "factorio-map-gen-settings.json"
|
|
(builtins.toJSON mapGenSettings)
|
|
}"
|
|
]);
|
|
};
|
|
};
|
|
}
|