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

98
flake.lock generated
View file

@ -128,6 +128,22 @@
"type": "github"
}
},
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
@ -209,6 +225,24 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
@ -362,6 +396,26 @@
"type": "github"
}
},
"nix-minecraft": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1750823009,
"narHash": "sha256-cawpGKdtw+2ai/fqvz+B8ge/iaX2CzbcDb39GiW5gt4=",
"owner": "Infinidoge",
"repo": "nix-minecraft",
"rev": "67cc1a9c77957e6749f38851c04ffbee6e0d4a4d",
"type": "github"
},
"original": {
"owner": "Infinidoge",
"repo": "nix-minecraft",
"type": "github"
}
},
"nix-unit": {
"inputs": {
"flake-parts": [
@ -391,7 +445,7 @@
},
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-compat": "flake-compat_3",
"nixpkgs": [
"nixpkgs"
]
@ -444,6 +498,22 @@
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1748929857,
"narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1750741721,
"narHash": "sha256-Z0djmTa1YmnGMfE9jEe05oO4zggjDmxOGKwt844bUhE=",
@ -459,7 +529,7 @@
"type": "github"
}
},
"nixpkgs_3": {
"nixpkgs_4": {
"locked": {
"lastModified": 1750731501,
"narHash": "sha256-Ah4qq+SbwMaGkuXCibyg+Fwn00el4KmI3XFX6htfDuk=",
@ -478,9 +548,9 @@
"nixvim": {
"inputs": {
"flake-parts": "flake-parts_3",
"nixpkgs": "nixpkgs_3",
"nixpkgs": "nixpkgs_4",
"nuschtosSearch": "nuschtosSearch",
"systems": "systems_3"
"systems": "systems_4"
},
"locked": {
"lastModified": 1750788551,
@ -498,7 +568,7 @@
},
"nuschtosSearch": {
"inputs": {
"flake-utils": "flake-utils",
"flake-utils": "flake-utils_2",
"ixx": "ixx",
"nixpkgs": [
"nixvim",
@ -552,8 +622,9 @@
"autofirma-nix": "autofirma-nix",
"home-manager": "home-manager_2",
"lanzaboote": "lanzaboote",
"nix-minecraft": "nix-minecraft",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2",
"nixpkgs": "nixpkgs_3",
"nixvim": "nixvim",
"sops-nix": "sops-nix"
}
@ -644,6 +715,21 @@
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [

View file

@ -29,9 +29,11 @@
url = "github:nix-community/NixOS-WSL/main";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-minecraft.url = "github:Infinidoge/nix-minecraft";
};
nixConfig = {
download-buffer-size = 524288000; # 500 MB
extra-substituters = [ "https://nix-community.cachix.org" ];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
@ -43,6 +45,7 @@
# Desktop computer
totsugeki = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./common/nixos.nix
./hosts/totsugeki/nixos
@ -69,12 +72,14 @@
# Home server
greatyamada = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./common/nixos.nix
./hosts/greatyamada/nixos
./hosts/greatyamada/services
inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModules.home-manager
inputs.nix-minecraft.nixosModules.minecraft-servers
{
home-manager = {
backupFileExtension = "bak";
@ -93,6 +98,7 @@
# WSL development system
mizuki = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./hosts/mizuki/nixos.nix
inputs.nixos-wsl.nixosModules.default

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