{ pkgs, lib, config, inputs, ... } : let inherit (lib) concatStringsSep; # Keys that can access the state of each instance (read/write!) over an rsync module # Leave empty to disable rsyncSSHKeys = config.users.users.defin.openssh.authorizedKeys.keys; jre17 = pkgs.temurin-bin-17; 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; }; jvmOpts = concatStringsSep " " [ "" # "-XX:+UseG1GC" # "-XX:+ParallelRefProcEnabled" # "-XX:MaxGCPauseMillis=200" # "-XX:+UnlockExperimentalVMOptions" # "-XX:+DisableExplicitGC" # "-XX:+AlwaysPreTouch" # "-XX:G1NewSizePercent=40" # "-XX:G1MaxNewSizePercent=50" # "-XX:G1HeapRegionSize=16M" # "-XX:G1ReservePercent=15" # "-XX:G1HeapWastePercent=5" # "-XX:G1MixedGCCountTarget=4" # "-XX:InitiatingHeapOccupancyPercent=20" # "-XX:G1MixedGCLiveThresholdPercent=90" # "-XX:G1RSetUpdatingPauseTimePercent=5" # "-XX:SurvivorRatio=32" # "-XX:+PerfDisableSharedMem" # "-XX:MaxTenuringThreshold=1" ]; in { # minecraft server is closed source # nixpkgs.config.allowUnfree = true; imports = [ inputs.modded-minecraft-servers.module ]; services.modded-minecraft-servers = { # This is mandatory for legal reasons. eula = true; # the name will be used for the state folder and system user. # in this case, the folder is '/var/lib/mc-deceasedcraft' # and the user is 'mc-deceasedcraft' instances.deceasedcraft = { enable = true; inherit rsyncSSHKeys jvmOpts; # jvmOpts = jvmOpts + " " + (concatStringsSep " " [ # "@libraries/net/minecraftforge/forge/1.18.2-40.2.4/unix_args.txt" # ]); jvmMaxAllocation = "1024m"; jvmInitialAllocation = "512m"; jvmPackage = jre17; # I believe these options match services.minecraft-server.serverProperties options serverConfig = defaults // { # Port must be unique server-port = 25565; rcon-port = 25566; motd = "Welcome to DeceasedCraft"; max-players = 10; allow-nether = false; spawn-protection=12; max-tick-time=600000; }; }; }; }