mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 15:33:13 +00:00
07c76c980c
Due to how complex minecraft world generation has gotten in recent years, it now can take several minutes to complete the first generation of a world seed, even on relatively new and powerful hardware. We are testing if a minecraft server can run inside of a nix enviroment, and not so much about stress testing the CI. Test running before this change: > (finished: waiting for TCP port 43000, in 118.49 seconds) Test running with this change: > (finished: waiting for TCP port 43000, in 27.88 seconds) Choice of using `level-type` and `generate-structures` was made as they support almost every version of minecraft. These two also make it extremely clear what it does, compared to the more complex `generator-settings` and all its toggles.
41 lines
1.0 KiB
Nix
41 lines
1.0 KiB
Nix
let
|
|
seed = "2151901553968352745";
|
|
rcon-pass = "foobar";
|
|
rcon-port = 43000;
|
|
in import ./make-test-python.nix ({ pkgs, ... }: {
|
|
name = "minecraft-server";
|
|
meta = with pkgs.lib.maintainers; { maintainers = [ nequissimus ]; };
|
|
|
|
nodes.server = { ... }: {
|
|
environment.systemPackages = [ pkgs.mcrcon ];
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
services.minecraft-server = {
|
|
declarative = true;
|
|
enable = true;
|
|
eula = true;
|
|
serverProperties = {
|
|
enable-rcon = true;
|
|
level-seed = seed;
|
|
level-type = "flat";
|
|
generate-structures = false;
|
|
online-mode = false;
|
|
"rcon.password" = rcon-pass;
|
|
"rcon.port" = rcon-port;
|
|
};
|
|
};
|
|
|
|
virtualisation.memorySize = 2047;
|
|
};
|
|
|
|
testScript = ''
|
|
server.wait_for_unit("minecraft-server")
|
|
server.wait_for_open_port(${toString rcon-port})
|
|
assert "${seed}" in server.succeed(
|
|
"mcrcon -H localhost -P ${toString rcon-port} -p '${rcon-pass}' -c 'seed'"
|
|
)
|
|
server.succeed("systemctl stop minecraft-server")
|
|
'';
|
|
})
|