{ minecraft, config, lib, ... }:
{
  imports = [
    minecraft.nixosModules.minecraft-servers
    ./servers/default.nix
  ];

  config = lib.mkIf config.system.server.enable {
    nixpkgs = {
      config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "minecraft-server" ];
      overlays = [ minecraft.overlay ];
    };

    services.minecraft-servers = {
      enable = true;
      eula = true;
    };

    environment.persistence."/persist".directories = [ "/srv/minecraft" ];
  };
}
