blob: f93a1396bfe5f8f52ae846ae8f84fcf5dc287922 (
plain) (
blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
{
config,
inputs,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.nixfiles.modules.games.minecraft;
in
{
imports = [ inputs.minecraft.nixosModules.minecraft-servers ];
options.nixfiles.modules.games.minecraft = {
client.enable = mkEnableOption "Minecraft client";
server = {
enable = mkEnableOption "Minecraft server";
port = mkOption {
description = "Server port.";
type = types.port;
default = 25565;
};
memory = mkOption {
description = "Amount of RAM to allocate.";
type = types.str;
default = "2G";
};
};
};
config = mkMerge [
(mkIf cfg.client.enable { hm.home.packages = [ pkgs.prismlauncher ]; })
(mkIf cfg.server.enable {
nixfiles.modules.common.nix.allowedUnfreePackages = [ "minecraft-server" ];
ark.directories = [ config.services.minecraft-servers.dataDir ];
services.minecraft-servers = {
enable = true;
eula = true;
openFirewall = true;
servers.default = {
enable = true;
autoStart = true;
# https://api.papermc.io/v2/projects/paper
# https://github.com/Infinidoge/nix-minecraft/blob/master/pkgs/paper-servers/lock.json
package = pkgs.paperServers.paper-1_21_47;
serverProperties = {
# motd = "";
# white-list = true;
allow-flight = true;
difficulty = "hard";
enable-command-block = true;
enforce-secure-profile = false;
enforce-whitelist = true;
gamemode = "survival";
level-name = "default";
max-players = 8;
online-mode = false;
previews-chat = false;
pvp = false;
server-port = cfg.server.port;
snooper-enabled = false;
};
jvmOpts =
(concatStringsSep " " [
"-Xms${cfg.server.memory}"
"-Xmx${cfg.server.memory}"
"--add-modules=jdk.incubator.vector" # Required by some plugins.
])
+ " ";
};
};
nixpkgs.overlays = [ inputs.minecraft.overlay ];
my.extraGroups = [ config.services.minecraft-servers.group ];
})
];
}
|