infrastructure/machines/public-cof/minecraft.nix
2022-12-03 21:15:40 +01:00

97 lines
3.4 KiB
Nix

{ lib, pkgs, ... }:
let
papermc = {
ram = 4; # In GB
version = "1.19.2";
build = 200;
sha256 = "sha256-fhQ1Kukp0MDF0312y/DR3wS9wKXY2aKUyU5f64ELylM=";
};
port = 25565;
rconPort = 25575;
in
{
# Remote administration
environment.systemPackages = [ pkgs.mcrcon ];
# Use papermc
nixpkgs.overlays = [
(self: super: {
minecraft-server = super.minecraft-server.overrideAttrs (old: {
src = pkgs.fetchurl {
url = with papermc;
"https://papermc.io/api/v2/projects/paper/versions/${version}/builds/${toString build}/downloads/paper-${version}-${toString build}.jar";
sha256 = papermc.sha256;
};
});
})
];
services.minecraft-server = {
enable = true;
eula = true;
declarative = true;
jvmOpts = with papermc;
"-Xms${toString ram}G -Xmx${toString ram}G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1";
# To get the uuids: https://mcuuid.net/
whitelist = {
gabriel_dr_dl = "53fced49-da51-4c82-b1d0-37168029db08";
aimie_dodo = "d10be020-a612-47e5-b0d0-938b9a7eb58e";
RaitoMezarius = "a400686e-0f62-43d5-b5c6-4295babcc008";
Sup3Legacy = "575ecb9f-bf28-46cb-bc50-cb6bb340c905";
Pollux3737 = "ffa65818-b022-4830-aa90-7f3211c8ee3d";
CiterinRemy = "2f6a0c0a-4c0e-4e6c-beb4-237600fba849";
clem197 = "7461bfdf-4dca-44c2-b035-b49d5740dfc5";
Clashis = "499fdd85-bbcb-446f-9611-8b6bb9bf6965";
skidijo = "6a72a1f4-7448-4fb7-a252-b6d5ceff2d43";
Tifendyll = "5dc1acf3-b214-4607-a3bd-924665e07c67";
OknShield = "ef12e9cd-121f-4b39-886e-89b5b4bc5f4f";
Allygon = "964a2ee3-3a0d-49c1-b8e9-60b5e69976d3";
CheesyBiggy = "574daaed-ce9a-4b33-a3af-055e39bc32dc";
H3raklio = "576969d4-94e7-49db-ba7e-e9e57ff5a75e";
thejohncrafter = "d3959974-3a05-4ab2-8acb-d8817c140d84";
};
serverProperties = {
server-port = port;
difficulty = "normal";
gamemode = "survival";
max-players = 42;
motd = "This is a test and it will break";
view-distance = 7;
# Map settings
level-seed = "9058136630944956755";
level-name = "Public_COF";
level-type = "default";
spawn-animals = true;
spawn-monsters = true;
spawn-npcs = true;
generate-structures = true;
enable-command-block = true;
# Whitelist
white-list = true;
enforce-whitelist = true;
# Admin
enable-rcon = true;
"rcon.password" =
''yQZ>O.%]fB{'E.X=HI1/En~i-''; # TODO Warning: it is written in clear in /var/lib/... with read permissions and mcrcom will transmit it without encryption
"rcon.port" = rconPort;
admin-slot = true;
snoop-enabled = false;
public = false;
# enable-jmx-monitoring = true; # https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html
};
};
networking.firewall.allowedTCPPorts = [ port ];
networking.firewall.allowedUDPPorts = [ port ];
}