From 2940656cf158fbd388d8b227334229fd6db9bb38 Mon Sep 17 00:00:00 2001 From: satr14 Date: Sat, 2 May 2026 18:41:49 +0700 Subject: [PATCH] mc server --- flake.lock | 70 ++++++++++++++++++++++++++++- flake.nix | 2 + lib/options.nix | 4 ++ modules/system/homelab/mc.nix | 73 +++++++++++++++++++++++++++++++ modules/system/misc/utilities.nix | 1 + modules/system/server.nix | 1 + 6 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 modules/system/homelab/mc.nix diff --git a/flake.lock b/flake.lock index e972eea..5970bab 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,22 @@ "type": "github" } }, + "flake-compat": { + "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-utils": { "inputs": { "systems": "systems" @@ -76,6 +92,26 @@ "type": "github" } }, + "mc": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs_3", + "systems": "systems_2" + }, + "locked": { + "lastModified": 1777692910, + "narHash": "sha256-rPszOFTm7gP9n/JGiFH4SeuEALC8FBJtXu5owvHVjaQ=", + "owner": "Infinidoge", + "repo": "nix-minecraft", + "rev": "0707737282f65e25ed8e6e73f8767872659b7fb8", + "type": "github" + }, + "original": { + "owner": "Infinidoge", + "repo": "nix-minecraft", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1776548001, @@ -108,6 +144,22 @@ } }, "nixpkgs_3": { + "locked": { + "lastModified": 1769461804, + "narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { "locked": { "lastModified": 1777268161, "narHash": "sha256-bxrdOn8SCOv8tN4JbTF/TXq7kjo9ag4M+C8yzzIRYbE=", @@ -128,7 +180,8 @@ "ctp": "ctp", "gl": "gl", "hm": "hm", - "nixpkgs": "nixpkgs_3" + "mc": "mc", + "nixpkgs": "nixpkgs_4" } }, "systems": { @@ -145,6 +198,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0c8d584..3ccbd5c 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,8 @@ gl.url = "github:nix-community/nixGL"; ctp.url = "github:catppuccin/nix"; + + mc.url = "github:Infinidoge/nix-minecraft"; }; outputs = inputs: let diff --git a/lib/options.nix b/lib/options.nix index 3a81736..9cc0282 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -54,9 +54,13 @@ in { [ "Dockge" "docker" "https://containers.proxy.${domain}" "http://localhost:5001/" ] ]; routes = { + "mc0.${domain}" = "tcp://localhost:25565"; + "docs-sandbox.${domain}" = "http://localhost:7090"; "docs.${domain}" = "http://localhost:7090"; + "cdn.${domain}" = selfSigned "https://localhost:3923"; + "git.${domain}" = "http://localhost:5080"; "auth.${domain}" = "http://localhost:1411"; "dash.${domain}" = "http://localhost:5070"; diff --git a/modules/system/homelab/mc.nix b/modules/system/homelab/mc.nix new file mode 100644 index 0000000..7ebfffd --- /dev/null +++ b/modules/system/homelab/mc.nix @@ -0,0 +1,73 @@ +{ inputs, pkgs, ... }: let + ram-allocation = "10240M"; + auth-server = "https://mc.satr14.my.id"; + # modpack = pkgs.fetchPackwizModpack { + # url = ""; + # packHash = ""; + # }; +in { + imports = [ inputs.mc.nixosModules.minecraft-servers ]; + nixpkgs.overlays = [ inputs.mc.overlay ]; + + services.minecraft-servers = { + enable = true; + eula = true; + + servers.mc0-explorers-creativity = { + enable = true; + autoStart = true; + restart = "always"; + enableReload = true; + + package = pkgs.fabricServers.fabric-26_1.override { loaderVersion = "0.19.2"; }; + jvmOpts = let + authlib-injector = pkgs.fetchurl { + url = "https://github.com/yushijinhun/authlib-injector/releases/download/v1.2.7/authlib-injector-1.2.7.jar"; + sha256 = "0av58bz0fn7wn9bf7sib62cn4vgkk4mr9mavpn2xiizzmk2lpwga"; + }; + in '' + -Xms${ram-allocation} -Xmx${ram-allocation} -javaagent:${authlib-injector}=${auth-server} + + -add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -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 -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 + ''; + + serverProperties = { + server-port = 25565; + server-name = "Digit Association"; + motd = "\u00a7lSeason 3\u00a7r - \u00a7dExplorers Creativity \ud83d\udd25"; + + difficulty = "normal"; + gamemode = "survival"; + max-world-size = 25000; + spawn-protection = 0; + pvp = true; + + online-mode = true; + enforce-secure-profile = false; + pevent-proxy-connections = false; + allow-flight = false; + player-idle-timeout = 0; + + # resource-pack = "https://cdn.satr14.my.id/public/fullslide-1.21.11.zip"; + # resource-pack-sha1 = "e0958dcef5755286f390c22280700c471ec34a65"; + # resource-pack-enforce = false; + + simulation-distance = 16; + view-distance = 4; + + enable-rcon = true; + sync-chunk-writes = false; + "rcon.password" = "howdy"; + "rcon.port" = 25575; + }; + + symlinks = { + # "resources/datapack/required" = "${modpack}/datapacks"; + # "mods" = "${modpack}/mods"; + + # "server-icon.png" = "${modpack}/server-icon.png"; + # "config" = ""; + }; + }; + }; +} \ No newline at end of file diff --git a/modules/system/misc/utilities.nix b/modules/system/misc/utilities.nix index 29c4c6f..de5d35e 100644 --- a/modules/system/misc/utilities.nix +++ b/modules/system/misc/utilities.nix @@ -74,6 +74,7 @@ lsof # Nix & Development + rcon-cli dconf2nix home-manager nix-index diff --git a/modules/system/server.nix b/modules/system/server.nix index 019d474..57a3ff0 100644 --- a/modules/system/server.nix +++ b/modules/system/server.nix @@ -25,6 +25,7 @@ in { ./homelab/cdn.nix ./homelab/ai.nix ./homelab/db.nix + ./homelab/mc.nix ./core/swapfile.nix ./core/oom.nix