diff options
Diffstat (limited to 'nixos/tests/minecraft-server.nix')
-rw-r--r-- | nixos/tests/minecraft-server.nix | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/nixos/tests/minecraft-server.nix b/nixos/tests/minecraft-server.nix new file mode 100644 index 0000000000000..53780e4636ca8 --- /dev/null +++ b/nixos/tests/minecraft-server.nix @@ -0,0 +1,37 @@ +let + seed = "2151901553968352745"; + rcon-pass = "foobar"; + rcon-port = 43000; +in import ./make-test-python.nix ({ pkgs, ... }: { + name = "minecraft-server"; + meta = with pkgs.stdenv.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; + online-mode = false; + "rcon.password" = rcon-pass; + "rcon.port" = rcon-port; + }; + }; + + virtualisation.memorySize = 2048; + }; + + 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'" + ) + ''; +}) |