Enable factorio on toothless
This commit is contained in:
parent
de24170e88
commit
86cc98699d
@ -2,107 +2,6 @@
|
|||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
# gdiw = let
|
|
||||||
# version = "0.17.5";
|
|
||||||
# sha256 = "0kg1jz26gpmldajckb47vgk9v6z6w0sf1lykl2pvjh0nq4mfl252";
|
|
||||||
# in pkgs.stdenv.mkDerivation {
|
|
||||||
# inherit version;
|
|
||||||
# pname = "gdiw";
|
|
||||||
# src = pkgs.fetchurl {
|
|
||||||
# inherit sha256;
|
|
||||||
# url =
|
|
||||||
# "https://github.com/DaCyclops/GDIW/archive/refs/tags/${version}.zip";
|
|
||||||
# };
|
|
||||||
# deps = [ ];
|
|
||||||
# phases = [ "installPhase" ];
|
|
||||||
# installPhase = ''
|
|
||||||
# mkdir $out
|
|
||||||
# cp $src $out/GDIW_${version}.zip
|
|
||||||
# '';
|
|
||||||
# };
|
|
||||||
|
|
||||||
# bottleneck = let
|
|
||||||
# version = "0.11.7";
|
|
||||||
# sha256 = "0mvk0wciqpggjc0vzhb7g0a0cxq0wdzvzwrbqvagr6y02j4h3y1n";
|
|
||||||
# in pkgs.stdenv.mkDerivation {
|
|
||||||
# inherit version;
|
|
||||||
# pname = "bottleneck";
|
|
||||||
# src = pkgs.fetchurl {
|
|
||||||
# inherit sha256;
|
|
||||||
# url =
|
|
||||||
# "https://github.com/troelsbjerre/Bottleneck/archive/refs/tags/${version}.zip";
|
|
||||||
# };
|
|
||||||
# deps = [ ];
|
|
||||||
# phases = [ "installPhase" ];
|
|
||||||
# installPhase = ''
|
|
||||||
# mkdir $out
|
|
||||||
# cp $src $out/Bottleneck_${version}.zip
|
|
||||||
# '';
|
|
||||||
# };
|
|
||||||
|
|
||||||
# even-distribution = let
|
|
||||||
# version = "1.0.10";
|
|
||||||
# commit-hash = "2f65d82a4da606b82bc597fce2695e7c512ebbfe";
|
|
||||||
# sha256 = "05y1j8mq2nm163h014510bkv0w06hn97z5v2kay36ilj0rzdpi6j";
|
|
||||||
# in pkgs.stdenv.mkDerivation {
|
|
||||||
# inherit version;
|
|
||||||
# pname = "even-distribution";
|
|
||||||
|
|
||||||
# src = pkgs.fetchurl {
|
|
||||||
# inherit sha256;
|
|
||||||
# url =
|
|
||||||
# "https://github.com/321freddy/even-distribution/archive/${commit-hash}.zip";
|
|
||||||
# };
|
|
||||||
# deps = [ ];
|
|
||||||
# phases = [ "installPhase" ];
|
|
||||||
# installPhase = ''
|
|
||||||
# mkdir $out
|
|
||||||
# cp $src $out/even-distribution_${version}.zip
|
|
||||||
# '';
|
|
||||||
# };
|
|
||||||
|
|
||||||
# mkPlugin = { name, version, url, sha256, deps ? [ ] }:
|
|
||||||
# let
|
|
||||||
# fetchurl-auth = { name, url, sha256 }:
|
|
||||||
# lib.overrideDerivation (pkgs.fetchurl {
|
|
||||||
# inherit name url sha256;
|
|
||||||
# curlOpts = [
|
|
||||||
# "--get"
|
|
||||||
# "-L"
|
|
||||||
# "-H"
|
|
||||||
# "Accept:application/octet-stream"
|
|
||||||
# "--data-urlencode"
|
|
||||||
# "username@username"
|
|
||||||
# "--data-urlencode"
|
|
||||||
# "token@token"
|
|
||||||
# ];
|
|
||||||
|
|
||||||
# }) (_:
|
|
||||||
# let
|
|
||||||
# username = "Exceeding9987";
|
|
||||||
# token =
|
|
||||||
# lib.readFile config.fudo.secrets.files.blobs."factorio-token.txt";
|
|
||||||
# in {
|
|
||||||
# preHook = if username != "" && token != "" then ''
|
|
||||||
# echo -n "${username}" >username
|
|
||||||
# echo -n "${token}" >token
|
|
||||||
# '' else ''
|
|
||||||
# # Deliberately failing since username/token was not provided, so we can't fetch.
|
|
||||||
# # We can't use builtins.throw since we want the result to be used if the tar is in the store already.
|
|
||||||
# exit 1
|
|
||||||
# '';
|
|
||||||
# });
|
|
||||||
# in pkgs.stdenv.mkDerivation {
|
|
||||||
# inherit version deps;
|
|
||||||
# pname = name;
|
|
||||||
# src = fetchurl-auth { inherit name url sha256; };
|
|
||||||
# phases = [ "installPhase" ];
|
|
||||||
# installPhase = ''
|
|
||||||
# mkdir $out
|
|
||||||
# cp $src $out/${name}_${version}.zip
|
|
||||||
# '';
|
|
||||||
# };
|
|
||||||
|
|
||||||
mods = let
|
mods = let
|
||||||
modFromFile = { file, deps, ... }:
|
modFromFile = { file, deps, ... }:
|
||||||
let basename = baseNameOf file;
|
let basename = baseNameOf file;
|
||||||
|
@ -5,51 +5,55 @@ let
|
|||||||
primaryIp = "10.0.0.12";
|
primaryIp = "10.0.0.12";
|
||||||
generateMac = pkgs.lib.network.generate-mac-address;
|
generateMac = pkgs.lib.network.generate-mac-address;
|
||||||
in {
|
in {
|
||||||
networking = {
|
imports = [ ./toothless/factorio.nix ];
|
||||||
useDHCP = false;
|
|
||||||
defaultGateway = {
|
|
||||||
address = "10.0.0.1";
|
|
||||||
interface = "intif0";
|
|
||||||
};
|
|
||||||
interfaces.intif0 = {
|
|
||||||
ipv4.addresses = [{
|
|
||||||
address = primaryIp;
|
|
||||||
prefixLength = 16;
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
security.sudo.extraConfig = ''
|
config = {
|
||||||
# Due to rollback, sudo will lecture after every reboot
|
networking = {
|
||||||
Defaults lecture = never
|
useDHCP = false;
|
||||||
'';
|
defaultGateway = {
|
||||||
|
address = "10.0.0.1";
|
||||||
|
interface = "intif0";
|
||||||
|
};
|
||||||
|
interfaces.intif0 = {
|
||||||
|
ipv4.addresses = [{
|
||||||
|
address = primaryIp;
|
||||||
|
prefixLength = 16;
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
fudo = {
|
security.sudo.extraConfig = ''
|
||||||
minecraft-clj = {
|
# Due to rollback, sudo will lecture after every reboot
|
||||||
enable = true;
|
Defaults lecture = never
|
||||||
state-directory = "/state/services/minecraft-clj";
|
'';
|
||||||
admins = [ "fudoniten" ];
|
|
||||||
worlds = {
|
fudo = {
|
||||||
REPLand = { allocated-memory = 8; };
|
minecraft-clj = {
|
||||||
wof = {
|
enable = true;
|
||||||
world-name = "WorldOfFun";
|
state-directory = "/state/services/minecraft-clj";
|
||||||
world-seed = 2059666523504992;
|
admins = [ "fudoniten" ];
|
||||||
port = 25567;
|
worlds = {
|
||||||
difficulty = "medium";
|
REPLand = { allocated-memory = 8; };
|
||||||
game-mode = "survival";
|
wof = {
|
||||||
motd = "Welcome to the World of Fun!";
|
world-name = "WorldOfFun";
|
||||||
allow-cheats = true;
|
world-seed = 2059666523504992;
|
||||||
allocated-memory = 16;
|
port = 25567;
|
||||||
pvp = false;
|
difficulty = "medium";
|
||||||
|
game-mode = "survival";
|
||||||
|
motd = "Welcome to the World of Fun!";
|
||||||
|
allow-cheats = true;
|
||||||
|
allocated-memory = 16;
|
||||||
|
pvp = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
systemd.targets = {
|
systemd.targets = {
|
||||||
sleep.enable = false;
|
sleep.enable = false;
|
||||||
suspend.enable = false;
|
suspend.enable = false;
|
||||||
hibernate.enable = false;
|
hibernate.enable = false;
|
||||||
hybrid-sleep.enable = false;
|
hybrid-sleep.enable = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
183
config/host-config/toothless/factorio.nix
Normal file
183
config/host-config/toothless/factorio.nix
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
{ 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);
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
|
config = {
|
||||||
|
services.factorio = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
# 'factorio' points to an old game
|
||||||
|
stateDirName = "krastorio2";
|
||||||
|
|
||||||
|
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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
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}")
|
||||||
|
(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)
|
||||||
|
}"
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -72,26 +72,25 @@ in {
|
|||||||
verbose = true;
|
verbose = true;
|
||||||
event-topics = cfg.event-topics;
|
event-topics = cfg.event-topics;
|
||||||
notification-topic = cfg.notification-topic;
|
notification-topic = cfg.notification-topic;
|
||||||
mqtt = let
|
mqtt =
|
||||||
host-secrets =
|
let host-secrets = config.fudo.secrets.host-secrets."${hostname}";
|
||||||
(trace hostname config.fudo.secrets.host-secrets."${hostname}");
|
in {
|
||||||
in {
|
incoming = {
|
||||||
incoming = {
|
port = config.fudo.services.mqtt.private.port;
|
||||||
port = config.fudo.services.mqtt.private.port;
|
host = config.fudo.services.mqtt.mqtt-hostname;
|
||||||
host = config.fudo.services.mqtt.mqtt-hostname;
|
username = "snooper";
|
||||||
username = "snooper";
|
password-file = host-secrets.snooper-passwd.target-file;
|
||||||
password-file = host-secrets.snooper-passwd.target-file;
|
};
|
||||||
|
outgoing = {
|
||||||
|
port = config.fudo.services.mqtt.public.port;
|
||||||
|
host = config.fudo.services.mqtt.mqtt-hostname;
|
||||||
|
username = "snooper";
|
||||||
|
password-file = host-secrets.snooper-passwd.target-file;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
outgoing = {
|
|
||||||
port = config.fudo.services.mqtt.public.port;
|
|
||||||
host = config.fudo.services.mqtt.mqtt-hostname;
|
|
||||||
username = "snooper";
|
|
||||||
password-file = host-secrets.snooper-passwd.target-file;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
tattler = mkIf cfg.enable-notifications {
|
tattler = mkIf cfg.enable-notifications {
|
||||||
enable = true;
|
enable = false;
|
||||||
verbose = true;
|
verbose = true;
|
||||||
notification-topic = cfg.notification-topic;
|
notification-topic = cfg.notification-topic;
|
||||||
mqtt = {
|
mqtt = {
|
||||||
|
14
flake.lock
generated
14
flake.lock
generated
@ -2034,11 +2034,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1683837890,
|
"lastModified": 1684342513,
|
||||||
"narHash": "sha256-y//EIz15wflQknpKzg8KqTYYcDJClFhZ85NN42Wm7cU=",
|
"narHash": "sha256-9pQgCf1/Lv3X2QhYjraoG0f6y0FobOhFX2OHEvm5ttc=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "0d65fc63b8e38501d3565ac5a40350bdeb2f8eff",
|
"rev": "5336a126bda3e2fcbec93bdd9254fa799f4a18eb",
|
||||||
"revCount": 136,
|
"revCount": 137,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.fudo.org/fudo-nix/entities.git"
|
"url": "https://git.fudo.org/fudo-nix/entities.git"
|
||||||
},
|
},
|
||||||
@ -3113,11 +3113,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_27": {
|
"nixpkgs_27": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1684171562,
|
"lastModified": 1684280442,
|
||||||
"narHash": "sha256-BMUWjVWAUdyMWKk0ATMC9H0Bv4qAV/TXwwPUvTiC5IQ=",
|
"narHash": "sha256-nC1/kfh6tpMQSLQalbNTNnireIlxvLLugrjZdasNh+I=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "55af203d468a6f5032a519cba4f41acf5a74b638",
|
"rev": "6c591e7adc514090a77209f56c9d0c551ab8530d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
Loading…
Reference in New Issue
Block a user