blob: 072c934cfb9c1415586dc4009d0763453f96921b (
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
45
46
47
48
49
50
51
52
53
54
55
56
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.services.minecraft-server;
in
{
options.modules.services.minecraft-server = {
enable = mkEnableOption "";
package = mkOption { type = types.package; default = pkgs.papermc; };
openFirewall = mkOption {
type = types.bool;
default = false;
};
bedrockSupport = mkOption {
type = types.bool;
default = false;
};
eula = mkOption {
type = types.bool;
default = false;
};
dataDir = mkOption {
type = types.str;
default = "/var/lib/minecraft";
};
};
config = mkIf cfg.enable {
services.minecraft-server = {
enable = true;
package = cfg.package;
declarative = false;
eula = cfg.eula;
dataDir = cfg.dataDir;
jvmOpts = "-Xms4096M -Xmx4096M"
+ " -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled"
+ " -XX:+UnlockExperimentalVMOptions"
+ " -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5"
+ " -XX:G1MaxNewSizePercent=40 -XX:G1NewSizePercent=30"
+ " -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90"
+ " -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20"
+ " -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200"
+ " -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32";
};
modules.persistence.directories = [
cfg.dataDir
];
networking.firewall.allowedTCPPorts = [ 25565 ]
++ optionals (cfg.bedrockSupport) [ 19132 ];
networking.firewall.allowedUDPPorts = [ 25565 ]
++ optionals (cfg.bedrockSupport) [ 19132 ];
};
}
|