From 76b5481df72d2d8bdcef0565aff64f847f5c38da Mon Sep 17 00:00:00 2001 From: ocfox Date: Sun, 28 Jan 2024 12:56:32 +0800 Subject: [PATCH] nixosTests.realm: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/realm.nix | 39 +++++++++++++++++++++++++++++++ pkgs/by-name/re/realm/package.nix | 8 +++++++ 3 files changed, 48 insertions(+) create mode 100644 nixos/tests/realm.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 8d67843a81ef..e6b4a4b66567 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -811,6 +811,7 @@ in { ragnarwm = handleTest ./ragnarwm.nix {}; rasdaemon = handleTest ./rasdaemon.nix {}; readarr = handleTest ./readarr.nix {}; + realm = handleTest ./realm.nix {}; redis = handleTest ./redis.nix {}; redlib = handleTest ./redlib.nix {}; redmine = handleTest ./redmine.nix {}; diff --git a/nixos/tests/realm.nix b/nixos/tests/realm.nix new file mode 100644 index 000000000000..b39b0e0a161c --- /dev/null +++ b/nixos/tests/realm.nix @@ -0,0 +1,39 @@ +import ./make-test-python.nix ({ lib, pkgs, ... }: { + name = "realm"; + + meta = { + maintainers = with lib.maintainers; [ ocfox ]; + }; + + nodes.machine = { pkgs, ... }: { + services.nginx = { + enable = true; + statusPage = true; + }; + # realm need DNS resolv server to run or use config.dns.nameserver + services.resolved.enable = true; + + services.realm = { + enable = true; + config = { + endpoints = [ + { + listen = "0.0.0.0:1000"; + remote = "127.0.0.1:80"; + } + ]; + }; + }; + }; + + testScript = '' + machine.wait_for_unit("nginx.service") + machine.wait_for_unit("realm.service") + + machine.wait_for_open_port(80) + machine.wait_for_open_port(1000) + + machine.succeed("curl --fail http://localhost:1000/") + ''; + +}) diff --git a/pkgs/by-name/re/realm/package.nix b/pkgs/by-name/re/realm/package.nix index 06356034682d..e76189e1ac8d 100644 --- a/pkgs/by-name/re/realm/package.nix +++ b/pkgs/by-name/re/realm/package.nix @@ -3,6 +3,8 @@ , fetchFromGitHub , stdenv , darwin +, nix-update-script +, nixosTests }: rustPlatform.buildRustPackage rec { @@ -24,6 +26,12 @@ rustPlatform.buildRustPackage rec { env.RUSTC_BOOTSTRAP = 1; + passthru = { + updateScript = nix-update-script { }; + tests = { inherit (nixosTests) realm; }; + }; + + meta = with lib; { description = "A simple, high performance relay server written in rust"; homepage = "https://github.com/zhboner/realm";