From b146700a708f6cab057c5aa0fb5c5b0e74706216 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Sat, 31 Oct 2026 09:31:25 -0400 Subject: [PATCH] mod: exposed some more options --- modules/games/homestead/README.md | 39 +++++++++++++++++++++++-- modules/games/homestead/default.nix | 21 +++++++++++-- modules/machine/krile/configuration.nix | 2 ++ 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/modules/games/homestead/README.md b/modules/games/homestead/README.md index 831fd98..d2460d2 100644 --- a/modules/games/homestead/README.md +++ b/modules/games/homestead/README.md @@ -56,18 +56,51 @@ recreated on each start and removed on stop by nix-minecraft. Edits to those copies do not persist across restarts. World data is not part of those managed directories. +Change the Minecraft port in `modules/machine/krile/configuration.nix`: + +```nix +services.homestead.port = 25566; +``` + +The default is TCP 25565. When `services.homestead.openFirewall = true`, the +opened TCP port follows this setting. Update your router's port forwarding and +connect with `krile:25566` (or your server's address). Voice chat remains on +UDP 24454, matching the pack's `config/voicechat/voicechat-server.properties`. +Rebuild krile to apply the change. + Change memory in the host configuration: ```nix services.homestead.jvmOpts = "-Xms6G -Xmx12G -XX:+UseG1GC"; ``` +Declare operators in the host configuration: + +```nix +services.homestead.operators = { + "YourMinecraftName" = { + uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + level = 4; + bypassesPlayerLimit = false; + }; +}; +``` + +Replace the example name and UUID with the player's actual Minecraft account +details. A UUID string also works as a shorthand: +`services.homestead.operators."YourMinecraftName" = "your-player-uuid";`. +It defaults to permission level 4 and does not bypass the player limit. + +After rebuilding krile, nix-minecraft generates +`/srv/minecraft/homestead/ops.json` when the server starts. A nonempty operator +list replaces the file on each start, so changes made with `/op` or `/deop` do +not persist across restarts. The default `{ }` leaves `ops.json` unmanaged. + Other server settings use the underlying nix-minecraft options: ```nix services.minecraft-servers.servers.homestead = { serverProperties = { - server-port = 25566; max-players = 10; white-list = true; }; @@ -76,8 +109,8 @@ services.minecraft-servers.servers.homestead = { }; ``` -Changing `server-port` also changes the opened TCP port. Voice chat remains on -UDP 24454, matching the pack's `config/voicechat/voicechat-server.properties`. +The underlying `serverProperties.server-port` setting can still override +`services.homestead.port`; the opened TCP port follows the effective value. To use this module on another NixOS host, pass `nur` in `specialArgs`, import `modules/games/homestead`, set `services.homestead.enable = true`, and set diff --git a/modules/games/homestead/default.nix b/modules/games/homestead/default.nix index 2004c6a..b475c65 100644 --- a/modules/games/homestead/default.nix +++ b/modules/games/homestead/default.nix @@ -2,6 +2,7 @@ config, lib, nur, + options, pkgs, ... }: @@ -15,12 +16,28 @@ in options.services.homestead = { enable = lib.mkEnableOption "the Homestead 2.0 Minecraft server"; + port = lib.mkOption { + type = lib.types.port; + default = 25565; + description = "TCP port for the Homestead Minecraft server."; + }; + openFirewall = lib.mkOption { type = lib.types.bool; default = false; description = "Open the Minecraft TCP port and Simple Voice Chat UDP port (24454)."; }; + operators = lib.mkOption { + type = (options.services.minecraft-servers.servers.type.getSubOptions [ ]).operators.type; + default = { }; + description = '' + Server operators keyed by Minecraft username. Values may be UUID strings + or attribute sets with uuid, level, and bypassesPlayerLimit. A nonempty + value manages ops.json declaratively; an empty value leaves it unmanaged. + ''; + }; + jvmOpts = lib.mkOption { type = lib.types.str; default = "-Xms6G -Xmx10G -XX:+UseG1GC"; @@ -35,7 +52,7 @@ in enable = true; servers.homestead = { enable = true; - inherit (cfg) openFirewall jvmOpts; + inherit (cfg) openFirewall operators jvmOpts; package = pkgs.fabricServers.fabric-1_20_1.override { loaderVersion = "0.19.5"; @@ -54,7 +71,7 @@ in max-tick-time = 180000; simulation-distance = 6; view-distance = 10; - server-port = 25565; + server-port = cfg.port; online-mode = true; # keep-inventory = true; }; diff --git a/modules/machine/krile/configuration.nix b/modules/machine/krile/configuration.nix index 8050595..1b0d347 100644 --- a/modules/machine/krile/configuration.nix +++ b/modules/machine/krile/configuration.nix @@ -80,7 +80,9 @@ services.homestead = { enable = true; + port = 25565; openFirewall = true; + operators = { }; }; services.minecraft-servers.eula = true;