{
  config,
  pkgs,
  lib,
  ...
}: let
  choose = paths: builtins.head (builtins.filter (p: builtins.pathExists p) paths);
  # Domain and Cloudflare DDNS records configured here. Update this list to add/remove records.
  domain = "prg-radio.org";
  modpack = pkgs.fetchModrinthModpack {
    # Get file from local system
    src = /srv/minecraft/modpacks/AllTheMods10-prg.mrpack;
    packHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
    side = "server";
  };
in {
  options.local = {
    hostname = lib.mkOption {
      type = lib.types.str;
      default = "nixos-default";
      description = "System hostname";
    };
    username = lib.mkOption {
      type = lib.types.str;
      default = "user";
      description = "Primary user username";
    };
    userDescription = lib.mkOption {
      type = lib.types.str;
      default = "NixOS User";
      description = "Primary user description";
    };
    address = lib.mkOption {
      type = lib.types.str;
      default = "10.1.1.100";
      description = "Static IP address";
    };
  };

  imports = [
    (choose [./modules/desktop-manager/sway_greetd_homemanager.nix ../desktop-manager/sway_greetd_homemanager.nix])
    (choose [./modules/local/hostname_username.nix ../local/hostname_username.nix])
    (choose [./modules/local/networking_local.nix ../local/networking_local.nix])
    (choose [./modules/bootloader/seabios-assigned-iso-at-birth.nix ../bootloader/seabios-assigned-iso-at-birth.nix])
    (choose [./modules/lix-default.nix ../lix-default.nix])
    # Optionally: (choose [ ./modules/toolsets/remote_building.nix ../toolsets/remote_building.nix ])
  ];

  config = {
    local.hostname = "nixos-minecraft";
    local.username = "minecraftprg";
    local.userDescription = "NixOS PRG Minecraft Service";
    local.address = "10.1.1.244";

    services.tailscale.enable = true;

    networking.firewall.allowedTCPPorts = [25565 25566 24454 8100 19132];
    networking.firewall.allowedUDPPorts = [25565 25566 24454 8100 19132];

    # 24454 - https://modrepo.de/minecraft/voicechat/wiki/server_setup_self_hosted !!!
    # This is the VoiceChat mod in Minecraft

    # Install psql
    services.postgresql = {
      enable = true;
    };
    # ---------------------------------------------------------------------------
    # Minecraft server configuration (nix-minecraft)
    # ---------------------------------------------------------------------------
    services.minecraft-servers = {
      enable = true;
      eula = true;
      openFirewall = true;

      servers.all-the-mods-ten = {
        enable = true;
        autoStart = true;
        restart = "always";

        package = pkgs.neoforgeServers.neoforge;

        jvmOpts = lib.concatStringsSep " " [
          "-Xms28G"
          # Use 120GB of RA
          "-Xmx32G"

          "-XX:+UseG1GC"
          "-XX:+ParallelRefProcEnabled"
          "-XX:MaxGCPauseMillis=80"
          "-XX:+UnlockExperimentalVMOptions"
          "-XX:+DisableExplicitGC"
          "-XX:+AlwaysPreTouch"
          "-XX:G1NewSizePercent=30"
          "-XX:G1MaxNewSizePercent=50"
          "-XX:G1HeapRegionSize=16M"
          "-XX:G1ReservePercent=20"
          "-XX:G1MixedGCCountTarget=4"
          "-XX:InitiatingHeapOccupancyPercent=15"
          "-XX:G1MixedGCLiveThresholdPercent=90"
          "-XX:G1RSetUpdatingPauseTimePercent=5"
        ];

        serverProperties = {
          server-port = 25566;
          motd = "PRG Fabric Modded Server";
          difficulty = "hard";
          gamemode = "survival";
          max-players = 64;
          online-mode = true;
          white-list = false;
          spawn-protection = 0;
          view-distance = 9;
          simulation-distance = 3;
          enforce-secure-profile = false;
          enable-command-block = false;
          enable-rcon = false;
          require-resource-pack = false;
          level-seed = "-2032795982907864146";
        };

        # Grant operator privileges to the user with the given UUID.
        # Update `name` to the player's Minecraft username if you know it.
        operators = {
          username1 = {
            uuid = "5e52c4ba-9b1a-469b-8f68-b9d684eae31d";
            level = 4; # 4 = highest permission (operator)
            bypassesPlayerLimit = true;
          };
        };

        symlinks = {
          "mods" = "${modpack}/mods";
        };
        files = {
          "config" = "${modpack}/config";
        };
      };

      servers.fabric-modded = {
        enable = true;
        autoStart = true;
        restart = "always";

        package = pkgs.fabricServers.fabric-1_21_11.override {
          loaderVersion = "0.18.4";
        };

        jvmOpts = lib.concatStringsSep " " [
          "-Xms54G"
          # Use 120GB of RA
          "-Xmx120G"

          "-XX:+UseG1GC"
          "-XX:+ParallelRefProcEnabled"
          "-XX:MaxGCPauseMillis=80"
          "-XX:+UnlockExperimentalVMOptions"
          "-XX:+DisableExplicitGC"
          "-XX:+AlwaysPreTouch"
          "-XX:G1NewSizePercent=30"
          "-XX:G1MaxNewSizePercent=50"
          "-XX:G1HeapRegionSize=16M"
          "-XX:G1ReservePercent=20"
          "-XX:G1MixedGCCountTarget=4"
          "-XX:InitiatingHeapOccupancyPercent=15"
          "-XX:G1MixedGCLiveThresholdPercent=90"
          "-XX:G1RSetUpdatingPauseTimePercent=5"
        ];

        serverProperties = {
          server-port = 25565;
          motd = "PRG Fabric Modded Server";
          difficulty = "hard";
          gamemode = "survival";
          max-players = 128;
          online-mode = true;
          white-list = false;
          spawn-protection = 0;
          view-distance = 9;
          simulation-distance = 3;
          enforce-secure-profile = false;
          enable-command-block = false;
          enable-rcon = false;
          level-type = "terralith:amplified_large_biomes";
          #curl -sL "https://cdn.modrinth.com/data/HfNmMQ9E/versions/AIg6K6QE/Sparkles_26.1_v1.1.7.zip" | sha1sum | cut -d ' ' -f 1
          resource-pack = "https://cdn.modrinth.com/data/HfNmMQ9E/versions/AIg6K6QE/Sparkles_26.1_v1.1.7.zip";
          require-resource-pack = false;
          resource-pack-sha1 = "7fdbd1e5e02191731aaa5298a61d457133cc8b00";
        };

        # Grant operator privileges to the user with the given UUID.
        # Update `name` to the player's Minecraft username if you know it.
        operators = {
          username1 = {
            uuid = "5e52c4ba-9b1a-469b-8f68-b9d684eae31d";
            level = 4; # 4 = highest permission (operator)
            bypassesPlayerLimit = true;
          };
        };

        ## Add mods by fetching them from Modrinth and linking them into the server's mods directory.
        # Command to fetch and get the SHA512 hash of a mod file:
        # curl -sL "URL-HERE" | sha512sum | cut -d ' ' -f 1

        symlinks = {
          mods = pkgs.linkFarmFromDrvs "mods" (
            builtins.attrValues {
              Fabric-API = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/i5tSkVBH/fabric-api-0.141.3%2B1.21.11.jar";
                sha512 = "c20c017e23d6d2774690d0dd774cec84c16bfac5461da2d9345a1cd95eee495b1954333c421e3d1c66186284d24a433f6b0cced8021f62e0bfa617d2384d0471";
              };
              Lithium = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/gvQqBUqZ/versions/Ow7wA0kG/lithium-fabric-0.21.4%2Bmc1.21.11.jar";
                sha512 = "f14a5c3d2fad786347ca25083f902139694f618b7c103947f2fd067a7c5ee88a63e1ef8926f7d693ea79ed7d00f57317bae77ef9c2d630bf5ed01ac97a752b94";
              };

              LetMeDespawn = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/vE2FN5qn/versions/7gmpSYHk/LetMeDespawn-1.21.11-x-fabric-1.6.2.jar";
                sha512 = "e0a03faef8bc3e94de34be71b0e0c3a3129a65baf2290483d64637547bc6008b8658231be268342b98e4f0405c57e64b1a84c42185fbd043bec39c185a71cb48";
              };

              Clumps = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/Wnxd13zP/versions/OgBE8Rz4/Clumps-fabric-1.21.11-29.0.0.1.jar";
                sha512 = "3cff3cd2d600a6d84030b38ce6244143d13774d5287627bb7312adae5edc7ae2d9151a2c9c39a00681c354d549b0a62ac48c0077ba586cc10c00d32f39e87f18";
              };

              FerriteCore = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/uXXizFIs/versions/Ii0gP3D8/ferritecore-8.2.0-fabric.jar";
                sha512 = "3210926a82eb32efd9bcebabe2f6c053daf5c4337eebc6d5bacba96d283510afbde646e7e195751de795ec70a2ea44fef77cb54bf22c8e57bb832d6217418869";
              };

              Terralith = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/8oi3bsk5/versions/94lWUKHj/Terralith_1.21.11_v2.6.0_Fabric.jar";
                sha512 = "3513374822c9181e2ec6e95ea04e0533d837934b6fe02165f3bc1b7752eff14972d094fce840355928ffa27844bf456ca6bb2cc968c5ad147601a64de1005c09";
              };

              Chunky = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/fALzjamp/versions/1CpEkmcD/Chunky-Fabric-1.4.55.jar";
                sha512 = "3be0e049e3dea6256b395ccb1f7dccc9c6b23cb7b1f6a717a7cd1ca55f9dbda489679df32868c72664ebb28ca05f2c366590d1e1a11f0dc5f69f947903bad833";
              };

              # Add missing dependencies
              almanac = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/Gi02250Z/versions/Tcl38ycb/Almanac-1.21.11-x-fabric-1.6.2.jar";
                sha512 = "2341101d7c051ebeb31d0e05ebcaf7b6930da99f2a03d9cf9c782af9b1905be327a7248c5ad4a0e5c05928081bcff4c81729cff3505a6cfa4023b87f686fd735";
              };

              lithostitched = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/XaDC71GB/versions/s47RpVwc/lithostitched-1.6.1-fabric-1.21.11.jar";
                sha512 = "250f7cc0d67c2796cebbd496672d302c1837d2601f72cfc8a568994b6f2bdc3f71f662bd44681dbc702d076c61a2ca131cdc860e522546c34dc576e6d0cd7a03";
              };

              AppleSkin = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/EsAfCjCV/versions/59ti1rvg/appleskin-fabric-mc1.21.11-3.0.8.jar";
                sha512 = "d32206cb8d6fac7f0b579f7269203135777283e1639ccb68f8605e9f5469b5b54305fd36ba82c64b48b89ae4f1a38501bfb5827284520c3ec622d95edcfa34de";
              };

              SimpleVoiceChat = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/9eGKb6K1/versions/pFTZ8sqQ/voicechat-fabric-1.21.11-2.6.12.jar";
                sha512 = "afc78e3d8ca463fb783b00ec3d4cb938ff9249f088d077f8cd75f6c846419e0fe4916061f57a0b188a5c28565c934623c52113f476e69e82aecabaffc8e8fdcc";
              };

              VoiceChatEvilMod = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/qsSP2ZZ0/versions/9PqoA83N/vcinteraction-fabric-1.21.11-1.0.8.jar";
                sha512 = "c16e9233d4798333650e90006b0657a0e7c347703fbab5e9546d38ffc528f9df2bbf82bf2e4d0b49de2ec6891b3b550b6104b0d3a8b111527434359fc41c6411";
              };

              Incendium = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/ZVzW5oNS/versions/fwHirj8n/Incendium_1.21.x_v5.4.11.jar";
                sha512 = "42a6d14c290d799a99e51f2730403221a1d5be7863c796d275aa916e6735c02397390236a2ae01800566288419adebe7776c563d6a3c2e4a2f9245d375da88d7";
              };

              Nullscape = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/LPjGiSO4/versions/f87vU1jc/Nullscape_1.21.x_v1.2.17.jar";
                sha512 = "16e12725973e03284d1a9d71c750b9687b91d91789eae8df657aa0f90d3487a68687711e486e2e294800eb492c355960b09be43006f3e0c48f67fc91f4f30bc2";
              };

              Structury = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/aKCwCJlY/versions/MXU49bpN/Structory_1.21.x_v1.3.14.jar";
                sha512 = "0aa3b4e31f851a0136eb672dc87c629db0fdaf2dd4a943c5dde7518b45fd733c7077c128b5d7fba674657d29ff09268040ab7d2c82a57414a22a2ea163ad8149";
              };

              StructuryTowers = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/j3FONRYr/versions/lefqbuOP/Structory_Towers_1.21.x_v1.0.15.jar";
                sha512 = "4068a07e0b6b21da6f77b65ac731e01c920f0269830c5bdf4b27b5d8f5a384f170781123feaed83aff05fcd94738aa6e8c29ef1d01c2c9c5cc87c3b4ac52903a";
              };

              Ledger = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/LVN9ygNV/versions/c1d39lju/ledger-1.3.19.jar";
                sha512 = "91c6cdd9d8bcb6fb57f3ec83c968217b157d7d763724ba19e6d21711bf14bdefdfe2a5b03226bce65c77a0988c6b1d336535de9c9bae4193902a95fac17152a0";
              };

              FabricKotlin = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/Ha28R6CL/versions/ViT4gucI/fabric-language-kotlin-1.13.9%2Bkotlin.2.3.10.jar";
                sha512 = "498672ee88cf703685026e74f82a85e30d980c62a1c8cc14744cb73add09a857db8d585b405e19f558ec490613642750eb00e09d8ef5a3c9578bc52b53568d51";
              };

              Bluemap = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/swbUV1cr/versions/TROfpX7m/bluemap-5.16-fabric.jar";
                sha512 = "138c022c61ff7b37174351625bdb859d7b0fd1dd33b76a32d894dc6fd8fe1c3d3c5d2a8575a3e72a82ca84baaf3253c485085d8a415cc76d1ed20bbabe88ab25";
              };

              UniversalGraves = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/yn9u3ypm/versions/rZeFZ5ip/graves-3.10.2%2B1.21.11.jar";
                sha512 = "62b4e92a9f93585d65a4ef4965472a55f9c180cbc946d4f08ad1f801c59e967a0123b5b3fc6f444504f1088026c0eca65f9d530adee64721ea85ff7c8cc7eca8";
              };

              PolymerBundled = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/xGdtZczs/versions/wugBT1fU/polymer-bundled-0.15.2%2B1.21.11.jar";
                sha512 = "9c205ab398c324ee4dc376269d8aa5df64d11766b6418952a64d2df94f096e665f63eae0c4f0c66e22d03c6ff6767550d1777c28485340131e6556091199062a";
              };

              DisablePortals = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/ZzkyvOit/versions/2dW9seoH/no-portals-1.21.11-1.1.8.jar";
                sha512 = "7c2e08c526f1a8428711926151ed9b98b931c01770cd8c3689f85c3a54f4c848bdeacc720d0f9f34878c16d8c178628220cc38f5b961a316cba421cd71beab40";
              };

              GeyserMC = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/wKkoqHrH/versions/YgokOb0l/geyser-fabric-Geyser-Fabric-2.9.5-b1108.jar";
                sha512 = "6b000e5c6015d7e92577c79e0db5bf8870d31274802a83e0412034cc7cfe58559f57c8192b79218c0dd57b6be7e21fe1169da8b3790051eb7ee0bcb72f62006f";
              };

              Floodgate = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/bWrNNfkb/versions/wzwExuYr/Floodgate-Fabric-2.2.6-b54.jar";
                sha512 = "aae816d98e2233167602c053becb43ffb6880451296fab2f3c6a6cd4c8bdc8208955d73e1089f9acdd8c1dccee7835c0b33fc42413ab317d9a9feee7b29de1af";
              };

              TrueEnding = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/MCnBYP0b/versions/BWvn4Jtr/tru.e-ending-1.1.4d.jar";
                sha512 = "fc1f69d77ec073ecafe5df9dbfff97fa633be42bdf4b5fb8325fe55a6219db9cdb48db0b73ae4b110c667e2fcc37c7c5721c377a2f165bbff56bc612daa37432";
              };

              ArchitecturyAPI = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/lhGA9TYQ/versions/uNdfrcQ8/architectury-19.0.1-fabric.jar";
                sha512 = "7ca532844a0ed3d35e8515e13d1e84f8eadfceaae93281b79ad6b4dac253f4634e3dfcc7592f9543871dec117e1a3092c196ba5eae33735162de223be19dc4ad";
              };

              NeoEnchantPlus = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/BynmO8IO/versions/R942LDop/NeoEnchant-5.14.0.jar";
                sha512 = "1e9fbfef03f1884995959364c28b2004ffd9c04094e46ceb5c306023e2b0ca1c19365f97092a1fa9383a6e72c2cd47160993cfd7d2c50b15ff5c1bc1e1e33cac";
              };

              CustomBiomeSapling = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/CYGkXnUb/versions/jyLDOcvy/terralith-biome-saplings-1.1.6.jar";
                sha512 = "948b1e4ced7ea15a21bc7af78feebc32e31a23d5619bfff8c4efa6b9560e402c11e11bb5ba238d8a2940b20cad5d32adb5cc733c2c51b2949f6b5c962295a524";
              };

              # Beyond Enchant Uses the Datapack instead.

              UnderwaterEnchant = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/e8JtTY4h/versions/mWHa1dMI/underwaterenchanting-1.21.11-2.9.jar";
                sha512 = "b7c6ab6d257f9295c21600c512860f5dda5c49f46bd0102c555305d0e3bf5b87273cffd5acbc68ff0170a8068a40ac54b114b2137f43de63414049b158544c0f";
              };

              DistantHorizons = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/uCdwusMi/versions/GT3Bm3GN/DistantHorizons-2.4.5-b-1.21.11-fabric-neoforge.jar";
                sha512 = "a9f673fac1f6f554b7394168cbe726f1a15eb2bbef1b65b3c9979853af8de70bf13a457c88ebdc30b955a071d519e86c631cdbf1dd39cdab7c73b9c2d7f165e1";
              };

              AddCollective = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/e0M1UDsY/versions/T8rv7kwo/collective-1.21.11-8.13.jar";
                sha512 = "af145a48ac89346c7b1ffa8c44400a91a9908e4d1df0f6f1a603ff045b1fd82d9aa041aea27a682c196b266c0daf84cb5b7b8d83b07ee53e2bc1a5c210d19a1b";
              };

              FastBackups = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/ZHKrK8Rp/versions/yqaOm9Fj/fastback-0.30.0%2B1.21.11-fabric.jar";
                sha512 = "2e000940838b79990818e5e9e97fd4326285f516c3bd761b0d8d6d560bc3a289d9b409b49b0adda0a7013da029ccdd5eef2c5299f98fcf891c1c2ea19bcaf639";
              };

              DatapackInjector = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/9nFfpUyI/versions/YOktbaoF/datapack-injector-fabric-1.0.0%2B1.21.11.jar";
                sha512 = "174308e26bb4d22371f01204cf5e55a95914005f63eb8562e8f859e5da6d6a095fe3d9e634af0243893e2d2fbbbb2704c901d093422b92a28c7fd360fed0abda";
              };

              Peek = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/TnOXNf5e/versions/dWLOrrLE/peek-fabric-1.21.11-1.4.9.jar";
                sha512 = "c62fbb5af2a5146fbe8cbf111cd31fa02bbf97f2334597f190694286371174f15fa571d81e33d9372cf4ec0062bae3543722c111f3e4f1edadfc672cf412c82a";
              };

              Spark = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/l6YH9Als/versions/gonLOAU1/spark-1.10.170-fabric.jar";
                sha512 = "7460ac92a1241f373238b7afe3c9e8dc67101d3cc6d95322f9a86b7db4dc3be5da5e3ce80ad9653bff682f796a79cd8384851e0ed757b468f2f52b6bde71cb00";
              };

              ItemSwapper = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/RPOSBQgq/versions/Fk9Fszur/itemswapper-fabric-0.10.0-mc1.21.11.jar";
                sha512 = "6b30f301d6650bf72fc081fb546e2ce54004bacee1123547be179e43edcf68a56040e565ccf1df7d8d27978e10fc99c5778cf9bfb8e0999ad78fe80c159009f0";
              };

              ViewDistanceFix = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/nxrXbh5K/versions/13lPLnFp/viewdistancefix-fabric-1.21.11-1.0.2.jar";
                sha512 = "00d48e17596689bcf745d3a01329fcf9ec657885446d55adb9a69b2d515ae4cc67b45943ff59ad3661d4c88643acb619dcc2045b4cd9a95220986697ded3fbd5";
              };

              ArmorPoser = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/PFwYNrHb/versions/pqoCZONH/ArmorPoser-fabric-1.21.11-13.2.0.jar";
                sha512 = "7d83b60cde24e5ffd00f14a3adc333cdbdedc2cdebff9249de1ca33bc190479b1b5adb8d0c9903bf32bb5938608d8ab0121edbfca0f6eb77380b72729b7f59fc";
              };

              ClothConfig = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/9s6osm5g/versions/xuX40TN5/cloth-config-21.11.153-fabric.jar";
                sha512 = "8f455489d4b71069e998568cf4e1450116f4360a4eb481cd89117f629c6883164886cf63ca08ac4fc929dd13d1112152755a6216d4a1498ee6406ef102093e51";
              };

              EnhancedGroups = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/1LE7mid6/versions/TZsIDYOE/enhancedgroups-fabric-1.21.11-1.7.1.jar";
                sha512 = "fba198429a362c4cc81b1fae9125aff6fe64fce737517db5bdc57919692d6e0046b3f33d79e1a06c2e2fb8eaf5a8a995dde406ec47a48894f83322c969026bf4";
              };

              SkinRestorer = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/ghrZDhGW/versions/64YNvBfd/skinrestorer-2.7.0%2B1.21.11-fabric.jar";
                sha512 = "5a32010cde723696841709b3250256e543b593fe5c1e8c088078f64854a08baffb2b5f1e8addc7e8a6a90607a5ecd6549f457fead247e5a6fb7989868c50f739";
              };

              SHA1Runtime = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/YoRtMPzM/versions/xOPNzoIc/SHA1Runtime-1.21.11-1.4.1.jar";
                sha512 = "6da7488f9ea99bc0d318280063197d1fbacf60199bcb138d642576437033e8813c05ccc89e80eb7786b2237deef29a9ff6f0669e9dc2915811c32cf5081dd8bc";
              };

              Status = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/b93awgkg/versions/Dw8gVR1R/status-fabric-1.21.11-1.1.0.jar";
                sha512 = "1fe57f557cf5c46bf2360c58d25f7b2b200222cebfec3534ec23734baa1bc23d1375bb04b7c024b6ef9491443de58afccfe56a727e6a222f8d5c4a8fc1e18232";
              };

              AudioPlayer = pkgs.fetchurl {
                url = "https://cdn.modrinth.com/data/SRlzjEBS/versions/cxRGd2KF/audioplayer-fabric-2.1.0%2B1.21.11.jar";
                sha512 = "81a1c432e51812e5ff7a2f3ea8030191d1f53ae4a3d42ab647358f52327e890c6d22b779c1ec02c5e92a3e438851d26aa6709dbb44af2d05fdd7c7d34e2f1dd4";
              };
            }
          );
        };
      };
    };

    # For FastBackup force etc to have PATH
    systemd.services."minecraft-server-fabric-modded".environment = {
      PATH = lib.mkForce (
        lib.makeBinPath [
          pkgs.git
          pkgs.git-lfs
          pkgs.coreutils
          pkgs.findutils
          pkgs.gnugrep
          pkgs.gnused
          pkgs.systemd
        ]
        + ":/run/current-system/sw/bin"
      );
    };

    # The nix-minecraft module creates the `minecraft` user/group automatically.
    users.users.minecraftprg.extraGroups = ["minecraft"];

    environment.systemPackages = with pkgs; [
      postgresql_jdbc
      git
      git-lfs
    ];

    system.stateVersion = "25.11";
  };
}
