diff --git a/flake.nix b/flake.nix index 475350a..a7d1c5d 100644 --- a/flake.nix +++ b/flake.nix @@ -73,9 +73,13 @@ "nixos-minecraft" = nixpkgs.lib.nixosSystem { inherit system; modules = [ - ./nix-system-configs/modules/system/minecraft.nix + # Apply the overlay first so pkgs in later modules (like our local + # `minecraft.nix`) see the extra helpers provided by the overlay + { nixpkgs.overlays = [ inputs.nix-minecraft.overlay ]; } + nix-minecraft.nixosModules.minecraft-servers - {nixpkgs.overlays = [inputs.nix-minecraft.overlay];} + + ./nix-system-configs/modules/system/minecraft.nix ]; }; }; diff --git a/nix-system-configs/modules/system/minecraft.nix b/nix-system-configs/modules/system/minecraft.nix index 5d1128b..16f7359 100644 --- a/nix-system-configs/modules/system/minecraft.nix +++ b/nix-system-configs/modules/system/minecraft.nix @@ -7,6 +7,10 @@ choose = paths: builtins.head (builtins.filter (p: builtins.pathExists p) paths); # Domain and Cloudflare DDNS records configured here. Update this list to add/remove records. domain = "prg-radio.org"; + # Try to use the nix-minecraft helper if the overlay is present; otherwise + # fall back to a local path. If you use the fallback, ensure the path is an + # unpacked modpack directory with `mods` and `config` subdirectories. + modpack = /srv/minecraft/modpacks/AllTheMods10-prg.mrpack; in { options.local = { hostname = lib.mkOption { @@ -48,8 +52,8 @@ in { services.tailscale.enable = true; - networking.firewall.allowedTCPPorts = [25565 24454 8100 19132]; - networking.firewall.allowedUDPPorts = [25565 24454 8100 19132]; + networking.firewall.allowedTCPPorts = [25565 25566 24454 8100 19132]; + networking.firewall.allowedUDPPorts = [25565 25566 24454 8100 19132]; # 24454 - https://modrepo.de/minecraft/voicechat/wiki/server_setup_self_hosted !!! # This is the VoiceChat mod in Minecraft @@ -66,6 +70,57 @@ in { eula = true; openFirewall = true; + servers.all-the-mods-ten = { + enable = true; + autoStart = true; + restart = "always"; + + package = pkgs.neoforgeServers.neoforge-1_21_1-21_1_220; + + jvmOpts = lib.concatStringsSep " " [ + "-Xms28G" + # Use 120GB of RA + "-Xmx32G" + ]; + + serverProperties = { + server-port = 25566; + motd = "The Sub Server All the Mods 10"; + difficulty = "hard"; + gamemode = "survival"; + max-players = 64; + online-mode = true; + white-list = false; + spawn-protection = 0; + view-distance = 9; + simulation-distance = 3; + enforce-secure-profile = false; + enable-command-block = false; + enable-rcon = false; + require-resource-pack = false; + level-seed = "-2032795982907864146"; + }; + + # Grant operator privileges to the user with the given UUID. + # Update `name` to the player's Minecraft username if you know it. + operators = { + username1 = { + uuid = "5e52c4ba-9b1a-469b-8f68-b9d684eae31d"; + level = 4; # 4 = highest permission (operator) + bypassesPlayerLimit = true; + }; + }; + + symlinks = { + "mods" = "${modpack}/overrides/mods"; + }; + files = { + "config" = "${modpack}/overrides/config"; + "kubejs" = "${modpack}/overrides/kubejs"; + "datapacks" = "${modpack}/overrides/datapacks"; + }; + }; + servers.fabric-modded = { enable = true; autoStart = true; @@ -106,7 +161,7 @@ in { white-list = false; spawn-protection = 0; view-distance = 9; - simulation-distance = 4; + simulation-distance = 3; enforce-secure-profile = false; enable-command-block = false; enable-rcon = false; @@ -286,7 +341,6 @@ in { sha512 = "a9f673fac1f6f554b7394168cbe726f1a15eb2bbef1b65b3c9979853af8de70bf13a457c88ebdc30b955a071d519e86c631cdbf1dd39cdab7c73b9c2d7f165e1"; }; - AddCollective = pkgs.fetchurl { url = "https://cdn.modrinth.com/data/e0M1UDsY/versions/T8rv7kwo/collective-1.21.11-8.13.jar"; sha512 = "af145a48ac89346c7b1ffa8c44400a91a9908e4d1df0f6f1a603ff045b1fd82d9aa041aea27a682c196b266c0daf84cb5b7b8d83b07ee53e2bc1a5c210d19a1b"; diff --git a/nix-system-configs/modules/system/traefik.nix b/nix-system-configs/modules/system/traefik.nix index 39de6dc..9c7b9f4 100644 --- a/nix-system-configs/modules/system/traefik.nix +++ b/nix-system-configs/modules/system/traefik.nix @@ -305,6 +305,9 @@ in { minecraft = { address = "[::]:25565"; }; + minecraft_modded = { + address = "[::]:25566"; + }; # Minecraft Bedrock (default port 19132) - expose both TCP and UDP minecraft-bedrock-tcp = {address = "[::]:19132";}; @@ -663,6 +666,11 @@ in { {address = "10.1.1.244:25565";} ]; }; + minecraft_modded.loadBalancer = { + servers = [ + {address = "10.1.1.244:25566";} + ]; + }; # TCP service for Minecraft Bedrock minecraft-bedrock-tcp.loadBalancer = { @@ -1041,8 +1049,8 @@ in { }; # Allow common HTTP/S and control ports, - networking.firewall.allowedTCPPorts = [80 443 10022 30033 8448 9001 3001 993 465 25 25565 24454 2456 2457 2458 26000 1234 3979 2022 19132]; - networking.firewall.allowedUDPPorts = [80 443 9987 9001 3001 993 465 25 25565 24454 2022 2456 2457 2458 26000 1234 3979 2022 19132]; + networking.firewall.allowedTCPPorts = [80 443 10022 30033 8448 9001 3001 993 465 25 25565 25566 24454 2456 2457 2458 26000 1234 3979 2022 19132]; + networking.firewall.allowedUDPPorts = [80 443 9987 9001 3001 993 465 25 25565 25566 24454 2022 2456 2457 2458 26000 1234 3979 2022 19132]; system.stateVersion = "25.11"; };