aboutsummaryrefslogtreecommitdiff
path: root/nix/minecraft.nix
diff options
context:
space:
mode:
authorAlexander Kassouni <alex@kassouni.net>2026-09-27 22:07:56 -0700
committerAlexander Kassouni <alex@kassouni.net>2026-09-27 22:08:31 -0700
commite037e164c5c45ff33525d0c8575e8d9e0315ac7b (patch)
treed350808fdb003a196b5c31b6bd2ad5c77345e0aa /nix/minecraft.nix
parent4072628986ccb63a8107e58a6aa35dc6056ded4b (diff)
move nix modules
Diffstat (limited to 'nix/minecraft.nix')
-rw-r--r--nix/minecraft.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/nix/minecraft.nix b/nix/minecraft.nix
new file mode 100644
index 0000000..0022ec6
--- /dev/null
+++ b/nix/minecraft.nix
@@ -0,0 +1,54 @@
+{inputs, lib, pkgs, ...}: let
+ allowMinecraft = pkg: builtins.elem (lib.getName pkg) [ "minecraft-server" ];
+
+ unstable = import inputs.nixpkgs-unstable {
+ inherit (pkgs.stdenv.hostPlatform) system;
+ config.allowUnfreePredicate = allowMinecraft;
+ };
+in {
+ nixpkgs.config.allowUnfreePredicate = allowMinecraft;
+
+ environment.systemPackages = [ pkgs.mcrcon ];
+
+ networking.firewall.allowedTCPPorts = [ 25565 ];
+ networking.firewall.allowedUDPPorts = [ 25565 ];
+
+ services.minecraft-server = {
+ enable = true;
+ package = unstable.minecraft-server;
+ eula = true;
+ # openFirewall would also open rcon.port, so open the game port by hand
+ openFirewall = false;
+ declarative = true;
+ whitelist = {
+ mr_5aturn = "2b811fad-e419-401e-9185-70ab279219b5";
+ CiderDonuts = "7a992778-71bc-4650-83a1-53069369481b";
+ };
+ serverProperties = {
+ server-port = 25565;
+ difficulty = "normal";
+ gamemode = "survival";
+ max-players = 5;
+ white-list = true;
+
+ enable-rcon = true;
+ "rcon.port" = 25575;
+ "rcon.password" = "mooshroom";
+ };
+ jvmOpts = "-Xms4096M -Xmx4096M";
+ };
+
+ systemd.services.minecraft-server = {
+ startLimitBurst = 5;
+ startLimitIntervalSec = 300;
+ serviceConfig = {
+ NoNewPrivileges = true;
+
+ ProtectSystem = "full";
+
+ MemoryMax = "6G";
+ TasksMax = 512;
+ RestartSec = "10s";
+ };
+ };
+}