From 3dc828a8ed3809ea373245696e44f23ad15cd958 Mon Sep 17 00:00:00 2001 From: Devin Finlinson Date: Sat, 28 Mar 2026 00:38:20 -0600 Subject: added a second minecraft server --- flake.lock | 70 +++++++++++++++++++++++++++++++++++++- flake.nix | 1 + machines/biski/default.nix | 13 +++++-- modules/nixos/minecraft-server.nix | 44 ++++++++++++++++++++++-- 4 files changed, 121 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index ce3699d..c38d753 100644 --- a/flake.lock +++ b/flake.lock @@ -198,6 +198,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-utils": { "locked": { "lastModified": 1667395993, @@ -706,6 +722,26 @@ "type": "github" } }, + "nix-minecraft": { + "inputs": { + "flake-compat": "flake-compat_3", + "nixpkgs": "nixpkgs_3", + "systems": "systems_2" + }, + "locked": { + "lastModified": 1774666183, + "narHash": "sha256-3DNpGXzkyuIu3/gXNtLvB2oSqKY5z1QP5ajy3VZjVV0=", + "owner": "Infinidoge", + "repo": "nix-minecraft", + "rev": "7bcbe84d765e7fce5e267c569c718d8246336f3b", + "type": "github" + }, + "original": { + "owner": "Infinidoge", + "repo": "nix-minecraft", + "type": "github" + } + }, "nixlib": { "locked": { "lastModified": 1736643958, @@ -838,6 +874,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": 1774244481, "narHash": "sha256-4XfMXU0DjN83o6HWZoKG9PegCvKvIhNUnRUI19vzTcQ=", @@ -908,8 +960,9 @@ "modded-minecraft-servers": "modded-minecraft-servers", "nix-colors": "nix-colors", "nix-index-database": "nix-index-database", + "nix-minecraft": "nix-minecraft", "nixos-generators": "nixos-generators", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_4", "nixpkgs-old": "nixpkgs-old", "nixpkgs-unstable": "nixpkgs-unstable", "nushell-scripts": "nushell-scripts", @@ -968,6 +1021,21 @@ "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" + } + }, "wallpapers": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index c68bdd9..c117b3a 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,7 @@ }; modded-minecraft-servers.url = "github:mkaito/nixos-modded-minecraft-servers"; + nix-minecraft.url = "github:Infinidoge/nix-minecraft"; #secrets management, lock with git commit at 20xx/x/xx #......... diff --git a/machines/biski/default.nix b/machines/biski/default.nix index 594957a..d4b33b8 100644 --- a/machines/biski/default.nix +++ b/machines/biski/default.nix @@ -123,7 +123,7 @@ }; # Open ports in the firewall. - networking.firewall.allowedTCPPorts = [ 25565 ]; + networking.firewall.allowedTCPPorts = [ 25565 25567]; networking.firewall.allowedUDPPorts = [ 10514 ]; networking.nftables = { enable = true; @@ -140,11 +140,18 @@ enable = true; internalInterfaces = [ "eno1" ]; externalInterface = "tailscale0"; - forwardPorts = [{ + forwardPorts = [ + { sourcePort = 25565; proto = "tcp"; destination = "100.64.0.2:25565"; - }]; + } + { + sourcePort = 25567; + proto = "tcp"; + destination = "100.64.0.2:25567"; + } + ]; }; # Or disable the firewall altogether. diff --git a/modules/nixos/minecraft-server.nix b/modules/nixos/minecraft-server.nix index c365af6..f2e45fc 100644 --- a/modules/nixos/minecraft-server.nix +++ b/modules/nixos/minecraft-server.nix @@ -5,12 +5,14 @@ let # Leave empty to disable rsyncSSHKeys = config.users.users.defin.openssh.authorizedKeys.keys; jre17 = pkgs.temurin-bin-17; + jre21 = pkgs.temurin-bin-21; defaults = { # 5 minutes tick timeout, for heavy packs max-tick-time = 5 * 60 * 1000; # It just ain't modded minecraft without flying around allow-flight = true; + max-players = 10; }; jvmOpts = concatStringsSep " " [ @@ -39,7 +41,32 @@ in { # minecraft server is closed source # nixpkgs.config.allowUnfree = true; - imports = [ inputs.modded-minecraft-servers.module ]; + imports = [ + inputs.modded-minecraft-servers.module + # inputs.nix-minecraft.nixosModules.minecraft-servers + ]; + # services.minecraft-servers = { + # enable = true; + # eula = true; + # openFirewall = true; + # servers.deceasedcraft-beta = { + # enable = true; + # package = pkgs.neoforgeServers.neoforge-1_20_1; + # serverProperties = defaults // { + # server-port = 25567; + # rcon-port = 25568; + # motd = "Welcome to DeceasedCraft Beta"; + # allow-nether = false; + # spawn-protection = 12; + # }; + # symlinks = { + # "mods" = /var/lib/mc-deceasedcraft-beta/mods; + # # "mods" = pkgs.linkFarmFromDrvs "mods" builtins.attrValues { + # # DeceasedCraftBeta = fetchurl { url = "https://mediafilez.forgecdn.net/files/7623/211/DeceasedCraft_Beta-5.10.16.zip"}; + # # }; + # }; + # }; + # }; services.modded-minecraft-servers = { # This is mandatory for legal reasons. eula = true; @@ -64,10 +91,21 @@ in { server-port = 25565; rcon-port = 25566; motd = "Welcome to DeceasedCraft"; - max-players = 10; allow-nether = false; spawn-protection=12; - max-tick-time=600000; + }; + }; + instances.deceasedcraft-beta = { + enable = true; + inherit rsyncSSHKeys jvmOpts; + jvmPackage = jre21; + + serverConfig = defaults // { + server-port = 25567; + rcon-port = 25568; + motd = "Welcome to DeceasedCraft Beta"; + allow-nether = false; + spawn-protection = 12; }; }; }; -- cgit v1.2.3