summaryrefslogtreecommitdiff
path: root/modules/nixos/minecraft-server.nix
blob: 629c876ed96f34634fa6f9b0589a4974200bcfaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ pkgs, config, inputs, ... } :
let
  # 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;
  };
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'
    deceasedcraft = {
      enable = true;
      inherit rsyncSSHKeys;
      jvmMaxAllocation = "8G";
      jvmInitialAllocation = "2G";
      jvmPackage = jre17;

      # I believe these options match services.minecraft-server.serverProperties options
      serverConfig = defaults // {
        # Port must be unique
        server-port = 25565;
        rcon-port = 25566;
        gamemode = "survival";
        motd = "Welcome to DeceasedCraft";
        max-players = 10;
      };
    };
  };
}