{ 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; 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 " " [ "" # "-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 # 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; # 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"; allow-nether = false; spawn-protection=12; }; }; 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; }; }; }; }