Minecraft Server: Difference between revisions
Removed flags from example, they were old and broken (causing minecraft-server to fail upon using them); instead recommended user to find their own flags. Also added a tip on changing server version/package |
|||
Line 6: | Line 6: | ||
== Setup == | == Setup == | ||
The minimum example to have a Minecraft server running on localhost at the default port of <code>25565</code>. By setting the <code>eula</code> option to <code>true</code>, you are agreeing to the [https://www.minecraft.net/en-us/eula Minecraft EULA] | The minimum example to have a Minecraft server running on localhost at the default port of <code>25565</code>. By setting the <code>eula</code> option to <code>true</code>, you are agreeing to the [https://www.minecraft.net/en-us/eula Minecraft EULA]. | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
Line 37: | Line 37: | ||
allow-cheats = true; | allow-cheats = true; | ||
}; | }; | ||
jvmOpts = "- | jvmOpts = "-Xms2048M -Xmx4096M"; | ||
}; | }; | ||
</nowiki>}} | </nowiki>}} | ||
You might want to look at using using [https://docs.papermc.io/paper/aikars-flags/ Aikar's flags] or the [https://github.com/brucethemoose/Minecraft-Performance-Flags-Benchmarks Minecraft performance flags benchmark]. | |||
== Tips and tricks == | == Tips and tricks == | ||
Line 45: | Line 46: | ||
=== Prefer IPv4 === | === Prefer IPv4 === | ||
To use IPv4 by default, add <code>-Djava.net.preferIPv4Stack=true</code> to <code>jvmOpts</code> | To use IPv4 by default, add <code>-Djava.net.preferIPv4Stack=true</code> to <code>jvmOpts</code>. | ||
< | === Use a different server version/package === | ||
</ | To use a specific server version, or another Minecraft server—such as [https://papermc.io/ PaperMC]—change <code>services.minecraft-server.package</code> to a nix package that represents your desired server. | ||
For example: | |||
<code>services.minecraft-server.package = pkgs.minecraftServers.vanilla-1-12;</code> | |||
or | |||
<code>services.minecraft-server.package = pkgs.papermc;</code> | |||
[[Category: Applications]] | [[Category: Applications]] | ||
[[Category: Gaming]] | [[Category: Gaming]] |
Revision as of 14:22, 18 August 2025
Minecraft Server is a server for the blocky sandbox game Minecraft. Currently only servers for the Java Edition of the game are supported.
Setup
The minimum example to have a Minecraft server running on localhost at the default port of 25565
. By setting the eula
option to true
, you are agreeing to the Minecraft EULA.
services.minecraft-server.enable = true;
services.minecraft-server.eula = true;
Configuration
This example is a more thorough declarative configuration that sets a few options including opening the firewall, restricting the server to only whitelisted users and setting the port to 43000
services.minecraft-server = {
enable = true;
eula = true;
openFirewall = true; # Opens the port the server is running on (by default 25565 but in this case 43000)
declarative = true;
whitelist = {
# This is a mapping from Minecraft usernames to UUIDs. You can use https://mcuuid.net/ to get a Minecraft UUID for a username
username1 = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
username2 = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy";
};
serverProperties = {
server-port = 43000;
difficulty = 3;
gamemode = 1;
max-players = 5;
motd = "NixOS Minecraft server!";
white-list = true;
allow-cheats = true;
};
jvmOpts = "-Xms2048M -Xmx4096M";
};
You might want to look at using using Aikar's flags or the Minecraft performance flags benchmark.
Tips and tricks
Prefer IPv4
To use IPv4 by default, add -Djava.net.preferIPv4Stack=true
to jvmOpts
.
Use a different server version/package
To use a specific server version, or another Minecraft server—such as PaperMC—change services.minecraft-server.package
to a nix package that represents your desired server.
For example:
services.minecraft-server.package = pkgs.minecraftServers.vanilla-1-12;
or
services.minecraft-server.package = pkgs.papermc;