1
0
Fork 0

Reconfigure Minecraft server to use nix-minecraft

This commit is contained in:
Avery 2025-06-26 00:10:57 +02:00
parent 8ab0c4b595
commit 35a65d995c
Signed by: Avery
GPG key ID: B684FD451B692E04
5 changed files with 197 additions and 281 deletions

View file

@ -1,33 +0,0 @@
# Managed by NixOS configuration
settings:
use-map-color-cache: true
allow-end: true
warn-on-overload: true
permissions-file: permissions.yml
update-folder: update
plugin-profiling: false
connection-throttle: 4000
query-plugins: true
deprecated-verbose: default
shutdown-message: Servidor cerrado
minimum-api: none
spawn-limits:
axolotls: 5
water-underground-creature: 5
monsters: 120
animals: 20
water-animals: 5
water-ambient: 20
ambient: 15
chunk-gc:
period-in-ticks: 600
ticks-per:
axolotl-spawns: 1
water-underground-creature-spawns: 1
animal-spawns: 400
monster-spawns: 1
water-spawns: 1
water-ambient-spawns: 1
ambient-spawns: 1
autosave: 6000
aliases: now-in-commands.yml

View file

@ -1,78 +1,104 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.minecraft-server;
bukkitConfigFile = ./bukkit.yml;
spigotConfigFile = ./spigot.yml;
cfgToString = v: if builtins.isBool v then lib.boolToString v else toString v;
eulaFile = builtins.toFile "eula.txt" ''
# eula.txt managed by NixOS configuration
eula=true
'';
opsFile = builtins.toFile "ops.json" (builtins.toJSON [{
name = "aveeeeryy";
uuid = "b65a1bc3-c6a0-4e8c-99b8-3538cfec0cfc";
level = 4;
bypassesPlayerLimit = true;
}]);
serverPropertiesFile = pkgs.writeText "server.properties" (''
# server.properties managed by NixOS configuration
'' + lib.concatStringsSep "\n"
(lib.mapAttrsToList (n: v: "${n}=${cfgToString v}") cfg.serverProperties));
serverIcon = ./server-icon.png;
{ config, pkgs, inputs, ... }:
let serverIcon = ./server-icon.png;
in {
services.minecraft-server = {
enable = false;
package = pkgs.papermc;
declarative = true;
environment.systemPackages = with pkgs; [ mcrcon ];
networking.firewall.allowedTCPPorts = [ 13914 ];
nixpkgs.overlays = [ inputs.nix-minecraft.overlay ];
services.minecraft-servers = {
enable = true;
eula = true;
openFirewall = true;
jvmOpts =
"-Xms6G -Xmx6G -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 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true";
serverProperties = {
difficulty = "hard";
enable-rcon = false;
enforce-secure-profile = false;
enforce-whitelist = true;
hide-online-players = true;
motd = "NixOS server";
online-mode = true;
pvp = true;
server-port = 13914;
spawn-protection = 0;
white-list = true;
# dataDir = "/mnt/ssd-01/minecraft";
# dataDir = "/mnt/Datos/minecraft";
environmentFile = config.sops.templates."minecraft.env".path;
managementSystem = {
tmux.enable = false;
systemd-socket.enable = true;
};
servers.main = {
enable = true;
package = pkgs.paperServers.paper-1_21_6;
enableReload = true;
autoStart = false;
jvmOpts =
"-Xms6G -Xmx6G -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 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true";
serverProperties = {
difficulty = "hard";
enable-rcon = true;
enable-query = false;
enforce-secure-profile = false;
enforce-whitelist = true;
hide-online-players = true;
max-players = 10;
motd = "NixOS server";
online-mode = true;
pvp = true;
"rcon.password" = "@MINECRAFT_RCON_PASSWORD@";
server-port = 13914;
spawn-protection = 0;
white-list = true;
};
symlinks = {
"server-icon.png" = serverIcon;
"plugins/EssentialsX.jar" = pkgs.fetchurl {
url =
"https://github.com/EssentialsX/Essentials/releases/download/2.21.1/EssentialsX-2.21.1.jar";
hash = "sha256-Fd1/hxPmE6Hd6tp5LbZgqIyL9pAVvBPxqfnjf21Ez1o=";
};
"plugins/EssentialsX-Chat.jar" = pkgs.fetchurl {
url =
"https://github.com/EssentialsX/Essentials/releases/download/2.21.1/EssentialsXChat-2.21.1.jar";
hash = "sha256-M3ThA5j5DI1qTdNw8OvLIprxRCD5q5ya/AfO5jGyU6Y=";
};
"plugins/TabTPS.jar" = pkgs.fetchurl {
url =
"https://cdn.modrinth.com/data/cUhi3iB2/versions/DlhrDe98/tabtps-spigot-1.3.27.jar";
hash = "sha256-pWmcNKB0iAlVK4Ki5/vBOv8npOMyrUdxJ/7TbPXlpcI=";
};
};
files = {
"ops.json".value = [{
name = "engullejamones";
uuid = "b65a1bc3-c6a0-4e8c-99b8-3538cfec0cfc";
level = 4;
bypassesPlayerLimit = true;
}];
"whitelist.json".value = [{
name = "engullejamones";
uuid = "b65a1bc3-c6a0-4e8c-99b8-3538cfec0cfc";
}];
"plugins/TabTPS/display-configs/default.conf" = pkgs.writeTextFile {
name = "tabtps-display-config.conf";
text = ''
action-bar-settings {
allow=false
enable-on-login=false
}
boss-bar-settings {
allow=false
enable-on-login=false
}
permission=""
tab-settings {
allow=true
enable-on-login=true
footer-modules="ping,tps,mspt,cpu,memory"
header-modules=""
separator="<br>"
theme=default
}
'';
};
};
};
dataDir = "/minecraft";
};
# Overriden to have a non-declarative whitelist
systemd.services.minecraft-server.preStart = lib.mkForce ''
ln -sf ${eulaFile} eula.txt
cp -f ${bukkitConfigFile} bukkit.yml
chmod +w bukkit.yml
cp -f ${spigotConfigFile} spigot.yml
chmod +w spigot.yml
cp -f ${opsFile} ops.json
chmod +w ops.json
ln -sf ${serverIcon} server-icon.png
if [ -e .declarative ]; then
# Was declarative before, no need to back up anything
cp -f ${serverPropertiesFile} server.properties
else
# Declarative for the first time, backup stateful files
cp -b --suffix=.stateful ${serverPropertiesFile} server.properties
# server.properties must have write permissions, because every time
# the server starts it first parses the file and then regenerates it..
chmod +w server.properties
echo "Autogenerated file that signifies that this server configuration is managed declaratively by NixOS" \
> .declarative
fi
'';
sops = {
secrets."minecraft_rcon".owner = "minecraft";
templates."minecraft.env" = {
content = ''
MINECRAFT_RCON_PASSWORD=${config.sops.placeholder."minecraft_rcon"}
'';
owner = "minecraft";
};
};
users.groups.minecraft.members = [ "avery" ];
}

View file

@ -1,169 +0,0 @@
# Managed by NixOS configuration
config-version: 12
settings:
debug: false
bungeecord: false
sample-count: 12
player-shuffle: 0
user-cache-size: 1000
save-user-cache-on-stop-only: false
moved-wrongly-threshold: 0.0625
moved-too-quickly-multiplier: 10.0
timeout-time: 60
restart-on-crash: false
restart-script: ./start.sh
netty-threads: 4
log-villager-deaths: true
log-named-deaths: true
attribute:
maxHealth:
max: 2048.0
movementSpeed:
max: 2048.0
attackDamage:
max: 2048.0
messages:
whitelist: No estas en la whitelist
unknown-command:
Comando desconocido. Escribe "/help" para ver una lista con todos
los comandos.
server-full: El servidor esta lleno
outdated-client: Tu cliente de Minecraft está desactualizado, actualiza a la version {0}
outdated-server: El servidor está desactualizado, utiliza la version {0}
restart: El servidor se esta reiniciando
advancements:
disable-saving: false
disabled:
- minecraft:story/disabled
commands:
replace-commands:
- setblock
- summon
- testforblock
- tellraw
log: true
tab-complete: 0
send-namespaced: true
spam-exclusions:
- /skill
silent-commandblock-console: false
players:
disable-saving: false
stats:
disable-saving: false
forced-stats: {}
world-settings:
default:
seed-ancientcity: 20083232
seed-buriedtreasure: 10387320
seed-mineshaft: default
below-zero-generation-in-existing-chunks: true
simulation-distance: default
hopper-can-load-chunks: false
seed-nether: 30084232
seed-stronghold: default
thunder-chance: 100000
verbose: false
hopper-amount: 1
dragon-death-sound-radius: 0
seed-village: 10387312
seed-desert: 14357617
seed-igloo: 14357618
seed-jungle: 14357619
seed-swamp: 14357620
seed-monument: 10387313
seed-shipwreck: 165745295
seed-ocean: 14357621
seed-outpost: 165745296
seed-endcity: 10387313
seed-slime: 987234911
seed-bastion: 30084232
seed-fortress: 30084232
seed-mansion: 10387319
seed-fossil: 14357921
seed-portal: 34222645
max-tnt-per-tick: 100
hanging-tick-frequency: 100
zombie-aggressive-towards-villager: true
enable-zombie-pigmen-portal-spawns: true
item-despawn-rate: 6000
view-distance: default
arrow-despawn-rate: 1200
trident-despawn-rate: 1200
wither-spawn-sound-radius: 0
mob-spawn-range: 8
end-portal-sound-radius: 0
nerf-spawner-mobs: false
max-entity-collisions: 8
growth:
twistingvines-modifier: 100
weepingvines-modifier: 100
cavevines-modifier: 100
glowberry-modifier: 100
cactus-modifier: 100
cane-modifier: 100
melon-modifier: 100
mushroom-modifier: 100
pumpkin-modifier: 100
sapling-modifier: 100
beetroot-modifier: 100
carrot-modifier: 100
potato-modifier: 100
wheat-modifier: 100
netherwart-modifier: 100
vine-modifier: 100
cocoa-modifier: 100
bamboo-modifier: 100
sweetberry-modifier: 100
kelp-modifier: 100
entity-activation-range:
ignore-spectators: false
animals: 32
monsters: 32
raiders: 48
misc: 16
water: 16
villagers: 32
flying-monsters: 32
villagers-work-immunity-after: 100
villagers-work-immunity-for: 20
villagers-active-for-panic: true
tick-inactive-villagers: true
wake-up-inactive:
animals-max-per-tick: 4
animals-every: 1200
animals-for: 100
monsters-max-per-tick: 8
monsters-every: 400
monsters-for: 100
villagers-max-per-tick: 4
villagers-every: 600
villagers-for: 100
flying-monsters-max-per-tick: 8
flying-monsters-every: 200
flying-monsters-for: 100
ticks-per:
hopper-transfer: 8
hopper-check: 1
hunger:
jump-walk-exhaustion: 0.05
jump-sprint-exhaustion: 0.2
combat-exhaustion: 0.1
regen-exhaustion: 6.0
swim-multiplier: 0.01
sprint-multiplier: 0.1
other-multiplier: 0.0
max-tick-time:
tile: 50
entity: 50
squid-spawn-range:
min: 45.0
merge-radius:
exp: 3.0
item: 2.5
entity-tracking-range:
players: 48
animals: 48
monsters: 48
misc: 32
other: 64