at 25.11-pre 2.3 kB view raw
1{ lib, pkgs, ... }: 2{ 3 name = "velocity"; 4 meta = { 5 platforms = [ 6 "x86_64-linux" 7 "aarch64-linux" 8 ]; 9 maintainers = [ lib.maintainers.Tert0 ]; 10 }; 11 12 nodes.server = 13 { ... }: 14 { 15 imports = 16 let 17 mkVelocityService = name: pkg: { 18 systemd.sockets.${name} = { 19 socketConfig = { 20 ListenFIFO = "/run/${name}.stdin"; 21 Service = "${name}"; 22 }; 23 }; 24 systemd.services.${name} = { 25 serviceConfig = { 26 ExecStart = "${pkg}/bin/velocity"; 27 DynamicUser = true; 28 StateDirectory = "${name}"; 29 WorkingDirectory = "/var/lib/${name}"; 30 31 Sockets = "${name}.socket"; 32 StandardInput = "socket"; 33 StandardOutput = "journal"; 34 StandardError = "journal"; 35 }; 36 }; 37 }; 38 in 39 [ 40 (mkVelocityService "velocity-without-native" ( 41 pkgs.velocity.override { withVelocityNative = false; } 42 )) 43 (mkVelocityService "velocity-with-native" (pkgs.velocity.override { withVelocityNative = true; })) 44 ]; 45 46 environment.systemPackages = [ pkgs.mcstatus ]; 47 }; 48 49 testScript = '' 50 def test_velocity(name: str, native: bool): 51 server.start_job(name) 52 server.wait_for_unit(name); 53 server.wait_for_open_port(25565) 54 server.wait_until_succeeds(f"journalctl -b -u {name} | grep -q 'Booting up Velocity nixpkgs-${pkgs.velocity.version}...'") 55 connections_startup_query = "Connections will use epoll channels, libdeflate (.+) compression, OpenSSL 3.x.x (.+) ciphers" if native else "Connections will use epoll channels, Java compression, Java ciphers" 56 server.wait_until_succeeds(f"journalctl -b -u {name} | grep -q -E '{connections_startup_query}'") 57 server.wait_until_succeeds(f"journalctl -b -u {name} | grep -q 'Done ([0-9]*.[0-9]*s)!'"); 58 59 _, status_result = server.execute("mcstatus localhost:25565 status") 60 assert "A Velocity Server" in status_result 61 62 server.execute(f"echo stop > /run/{name}.stdin") 63 server.wait_for_closed_port(25565); 64 65 test_velocity("velocity-without-native", False) 66 test_velocity("velocity-with-native", True) 67 ''; 68}