+/garnix-minecraft
git clone https://git.julia.blue/+/garnix-minecraft
95bf3c2
main
1{ 2description = "garnix minecraft server" ; 3inputs = { 4nixpkgs . url = "github:NixOS/nixpkgs?ref=nixos-24.05" ; 5garnix-lib . url = "github:garnix-io/garnix-lib" ; 6packwiz2nix . url = "github:getchoo/packwiz2nix" ; 7nix-minecraft . url = "github:Infinidoge/nix-minecraft" ; 8}; 9outputs = inputs :{ 10nixosConfigurations . server = inputs . nixpkgs . lib . nixosSystem { 11modules = [ 12inputs . garnix-lib . nixosModules . garnix 13( { pkgs , nix-minecraft , ...} :{ 14 15# TODO: does persistence.name need to be unique per user? 16garnix . server = { enable = true ; persistence = { enable = true ; name = "minecraft" ; }; }; 17 18users . users . me = { 19isNormalUser = true ; 20extraGroups = [ "wheel" "systemd-journal" ]; 21openssh . authorizedKeys . keys = [ 22"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPCatP3klEjfQPSiJNUc3FRDdz927BG1IzektpouzOZR" 23]; 24}; 25 26services = { 27minecraft-server = { 28enable = true ; 29eula = true ; 30openFirewall = true ; 31enableReload = true ; 32declarative = true ; 33 34serverProperties = { 35gamemode = 1 ; # survival 36difficulty = 3 ; # hard 37motd = "minecraft server on garnix.io" ; 38 39# white-list = true; 40}; 41 42# whitelist = { 43# "username" = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; 44# }; 45 46package = pkgs . fabricServers . fabric-1_21_1 ; 47 48# see hotspot docs for more info: 49# https://docs.oracle.com/en/java/javase/11/gctuning/garbage-first-garbage-collector-tuning.html 50jvmOpts = builtins . concatStringsSep " " [ 51"-Xms2G" "-Xmx3G" 52"-XX:+CMSIncrementalPacing" "-XX:+CMSClassUnloadingEnabled" 53"-XX:+ParallelRefProcEnabled" "-XX:+DisableExplicitGC" 54]; 55}; 56 57# TODO: add some mods using moderinth fetcher fixed output derivations (or packwiz) 58# including carpet, any datapack/texturepack, and this prometheus exporter: 59# https://github.com/cpburnz/minecraft-prometheus-exporter 60 61# TODO: declaratively set up a grafana dashboard using: 62# https://grafana.com/grafana/dashboards/16508-minecraft-server-stats/ 63# also try to add chat/map/online players 64 65openssh . enable = true ; 66}; 67 68environment = { 69enableAllTerminfo = true ; 70systemPackages = [ 71pkgs . htop 72]; 73}; 74 75security . sudo . wheelNeedsPassword = false ; 76 77nixpkgs = { 78hostPlatform = "x86_64-linux" ; 79config . allowUnfree = true ; 80overlays = [ nix-minecraft . overlay ]; 81}; 82system . stateVersion = "24.05" ; 83}) 84]; 85}; 86}; 87}