From 9ae0a96678a55be511f1bec0ae91ea299bccbd85 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 26 Dec 2023 17:10:10 -0500 Subject: [PATCH] feat(servers): add minecraft server configs for nomi and cv --- devices/oksys/modules/unbound.nix | 6 +- devices/servivi/default.nix | 1 + devices/servivi/modules/minecraft.nix | 90 +++++++++++++++++++++++++++ flake.lock | 47 ++++++++++---- flake.nix | 5 ++ 5 files changed, 133 insertions(+), 16 deletions(-) create mode 100644 devices/servivi/modules/minecraft.nix diff --git a/devices/oksys/modules/unbound.nix b/devices/oksys/modules/unbound.nix index f4287be..7b690f4 100644 --- a/devices/oksys/modules/unbound.nix +++ b/devices/oksys/modules/unbound.nix @@ -32,13 +32,13 @@ "\"git.nelim.org. IN A 24.200.126.219\"" - "\"mc.nelim.org IN A 100.64.0.4\"" + "\"mc.nelim.org IN A 100.64.0.7\"" "\"_minecraft._tcp.mc.nelim.org. 180 IN SRV 0 0 25569 mc.nelim.org.\"" - "\"cv.nelim.org IN A 100.64.0.4\"" + "\"cv.nelim.org IN A 100.64.0.7\"" "\"_minecraft._tcp.cv.nelim.org. 180 IN SRV 0 0 25566 cv.nelim.org.\"" - "\"mc2.nelim.org IN A 100.64.0.4\"" + "\"mc2.nelim.org IN A 100.64.0.7\"" "\"_minecraft._tcp.mc2.nelim.org. 180 IN SRV 0 0 25560 mc2.nelim.org.\"" "\"ota.nelim.org. IN A 100.64.0.5\"" diff --git a/devices/servivi/default.nix b/devices/servivi/default.nix index 70f9f5e..e485cba 100644 --- a/devices/servivi/default.nix +++ b/devices/servivi/default.nix @@ -6,6 +6,7 @@ ../../modules/tailscale.nix ./modules/binary-cache.nix + ./modules/minecraft.nix ]; vars = { diff --git a/devices/servivi/modules/minecraft.nix b/devices/servivi/modules/minecraft.nix new file mode 100644 index 0000000..4bde9b4 --- /dev/null +++ b/devices/servivi/modules/minecraft.nix @@ -0,0 +1,90 @@ +{ + config, + nms, + pkgs, + ... +}: { + imports = [nms.nixosModules.default]; + + services.modded-minecraft-servers = { + eula = true; + user = config.vars.user; + group = "users"; + + instances = let + jre8 = pkgs.temurin-bin-8; + jre17 = pkgs.temurin-bin-17; + + defaults = { + spawn-protection = 0; + max-tick-time = 5 * 60 * 1000; + allow-flight = true; + }; + in { + # Vanilla Survival + sv = { + enable = false; + + serverConfig = + { + server-port = 25566; + + extra-options = { + }; + } + // defaults; + }; + + # Vanilla Creative + cv = { + enable = true; + + jvmMaxAllocation = "6G"; + jvmInitialAllocation = "2G"; + jvmPackage = jre17; + jvmOpts = ""; + + serverConfig = + { + server-port = 25569; + motd = "creative mode gaming"; + + extra-options = { + difficulty = "hard"; + enable-command-block = true; + enforce-whitelist = true; + gamemode = "creative"; + max-players = 6; + view-distance = 16; + }; + } + // defaults; + }; + + # Modded https://www.curseforge.com/minecraft/modpacks/nomi-ceu + nomi = { + enable = true; + + jvmMaxAllocation = "10G"; + jvmInitialAllocation = "2G"; + jvmPackage = jre8; + jvmOpts = ""; + + serverConfig = + { + server-port = 25560; + motd = "motd=Nomi CEu Server, v1.7-alpha-2"; + + extra-options = { + max-players = 8; + difficulty = 1; + view-distance = 10; + simulation-distance = 10; + level-type = "lostcities"; + }; + } + // defaults; + }; + }; + }; +} diff --git a/flake.lock b/flake.lock index de5eccd..774f8c4 100644 --- a/flake.lock +++ b/flake.lock @@ -358,11 +358,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1703525245, - "narHash": "sha256-uDkNQgMmmVtTDKvRjO2TmUwlKSV4gwMLGj5pGr3xDIM=", + "lastModified": 1703616278, + "narHash": "sha256-xipHN28RIfB36qNoqesh4NnE/M6YZbEiYhkPHS3BFhI=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "4f99e805b900b72f5e2bed54a1a44d10c8d54771", + "rev": "9fb50252d3a128466e80bfc2fb67b45dc923ad41", "type": "github" }, "original": { @@ -719,11 +719,11 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1703502790, - "narHash": "sha256-BMwU2OD7PB0ikWABs58c6kRkzxznIF/G8tacr9pENmE=", + "lastModified": 1703603738, + "narHash": "sha256-AffDlWbemuNEFQmjhLixdjsFsUOiNeM0VXAus9GcvNU=", "owner": "nix-community", "repo": "nixpkgs-wayland", - "rev": "95c67444c1886ed3cddd54da947237682c211c39", + "rev": "3200b78364a88e5397c3270018bfef29fa5d07e8", "type": "github" }, "original": { @@ -860,6 +860,26 @@ "type": "gitlab" } }, + "nms": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703619116, + "narHash": "sha256-FAs/EoccWduokTKuqYeRzW2o3Eb6T3SpgWDoqHGeFwU=", + "owner": "matt1432", + "repo": "nixos-minecraft-servers", + "rev": "cffa361baa1990558f96b18e454502b8ed74a8f1", + "type": "github" + }, + "original": { + "owner": "matt1432", + "repo": "nixos-minecraft-servers", + "type": "github" + } + }, "nmt": { "flake": false, "locked": { @@ -878,11 +898,11 @@ }, "nur": { "locked": { - "lastModified": 1703562846, - "narHash": "sha256-ZMoJ8o+ey78WUN4CVXWOD+XacH+uRuoZIFJFmB+mTug=", + "lastModified": 1703616738, + "narHash": "sha256-WtKFoGkZMY1gkUXOuKh/5xdo7dkn80dML7WHj77D1Dw=", "owner": "nix-community", "repo": "NUR", - "rev": "a40c29c5c7beb812885ef39f0682457655dc6017", + "rev": "72438aada38bcd28f4d91a4111874362085a67a6", "type": "github" }, "original": { @@ -926,6 +946,7 @@ "nix-on-droid": "nix-on-droid", "nixpkgs": "nixpkgs_4", "nixpkgs-wayland": "nixpkgs-wayland", + "nms": "nms", "nur": "nur", "nurl": "nurl", "secrets": "secrets", @@ -940,11 +961,11 @@ "sops-nix": "sops-nix" }, "locked": { - "lastModified": 1703563864, - "narHash": "sha256-sP2Hool59oPdB3pORlEYMg5Fhb+GSzGwSzeYl2+hBXQ=", + "lastModified": 1703564272, + "narHash": "sha256-wDP3A087LAIWXyuYOSlSB+3gzto4UXgYcap+TwZuGLs=", "ref": "refs/heads/main", - "rev": "810545ee6ef90fa41f8c0a28e5de45aa646f411c", - "revCount": 14, + "rev": "92f6bcc37d0098e939d183bc735eb65338ebdf2d", + "revCount": 15, "type": "git", "url": "ssh://git@git.nelim.org/matt1432/nixos-secrets" }, diff --git a/flake.nix b/flake.nix index c1f08f8..1cd2568 100644 --- a/flake.nix +++ b/flake.nix @@ -118,6 +118,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + nms = { + url = "github:matt1432/nixos-minecraft-servers"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + hyprland = { url = "github:hyprwm/Hyprland"; inputs.nixpkgs.follows = "nixpkgs";