Files
nix-config-v2/modules/games/homestead/default.nix
T
2026-10-27 13:47:25 -04:00

82 lines
2.1 KiB
Nix

{
config,
lib,
nur,
pkgs,
...
}:
let
cfg = config.services.homestead;
modpack = pkgs.callPackage ./package.nix { };
in
{
imports = [ nur.nixosModules.minecraft-servers ];
options.services.homestead = {
enable = lib.mkEnableOption "the Homestead 2.0 Minecraft server";
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open the Minecraft TCP port and Simple Voice Chat UDP port (24454).";
};
jvmOpts = lib.mkOption {
type = lib.types.str;
default = "-Xms6G -Xmx10G -XX:+UseG1GC";
description = "JVM options for Homestead. Leave additional RAM for the OS and native allocations.";
};
};
config = lib.mkIf cfg.enable {
nixpkgs.overlays = [ nur.overlays.minecraft ];
services.minecraft-servers = {
enable = true;
servers.homestead = {
enable = true;
inherit (cfg) openFirewall jvmOpts;
package = pkgs.fabricServers.fabric-1_20_1.override {
loaderVersion = "0.19.5";
jre_headless = pkgs.jdk17_headless;
};
managementSystem = {
tmux.enable = false;
systemd-socket.enable = true;
};
# Match the properties generated by the pack's startserver.sh.
serverProperties = lib.mapAttrs (_: lib.mkDefault) {
motd = "Homestead 2.0";
allow-flight = true;
max-tick-time = 180000;
simulation-distance = 6;
view-distance = 10;
server-port = 25565;
online-mode = true;
# keep-inventory = true;
};
symlinks = {
mods = "${modpack}/mods";
"server-icon.png" = "${modpack}/server-icon.png";
};
# Mods may rewrite their configs or generate files here. nix-minecraft
# supplies writable copies on each start and cleans them on stop.
files = lib.genAttrs [
"config"
"defaultconfigs"
"kubejs"
"scripts"
"patchouli_books"
] (dir: "${modpack}/${dir}");
};
};
networking.firewall.allowedUDPPorts = lib.mkIf cfg.openFirewall [ 24454 ];
};
}