From 161bec7296158d38e9192938b1cdf6c99a0ac720 Mon Sep 17 00:00:00 2001 From: Soispha Date: Fri, 1 Mar 2024 20:57:04 +0100 Subject: [PATCH 1/2] redlib: init at 0.31.0 Fixes: #292634 --- pkgs/by-name/re/redlib/package.nix | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 pkgs/by-name/re/redlib/package.nix diff --git a/pkgs/by-name/re/redlib/package.nix b/pkgs/by-name/re/redlib/package.nix new file mode 100644 index 000000000000..c3778b9cd0fa --- /dev/null +++ b/pkgs/by-name/re/redlib/package.nix @@ -0,0 +1,61 @@ +{ lib +, stdenv +, cacert +, nixosTests +, rustPlatform +, fetchFromGitHub +, darwin +}: +rustPlatform.buildRustPackage rec { + pname = "redlib"; + version = "0.31.0"; + + src = fetchFromGitHub { + owner = "redlib-org"; + repo = "redlib"; + rev = "refs/tags/v${version}"; + hash = "sha256-d3Jjs/a2EgdqRBTjXKwDDRnU6orb7RQGl1CVz9b9SdI="; + }; + + cargoHash = "sha256-2MugS0/MO85lQvDbiFwnsX4LYdk7TACDFR8OOLEFGUQ="; + + buildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + ]; + + checkFlags = [ + # All these test try to connect to Reddit. + "--skip=test_fetching_subreddit_quarantined" + "--skip=test_fetching_nsfw_subreddit" + "--skip=test_fetching_ws" + + "--skip=test_obfuscated_share_link" + "--skip=test_share_link_strip_json" + + "--skip=test_localization_popular" + "--skip=test_fetching_subreddit" + "--skip=test_fetching_user" + + # These try to connect to the oauth client + "--skip=test_oauth_client" + "--skip=test_oauth_client_refresh" + "--skip=test_oauth_token_exists" + ]; + + env = { + SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + }; + + passthru.tests = { + inherit (nixosTests) redlib; + }; + + meta = { + changelog = "https://github.com/redlib-org/redlib/releases/tag/v${version}"; + description = "Private front-end for Reddit (Continued fork of Libreddit)"; + homepage = "https://github.com/redlib-org/redlib"; + license = lib.licenses.agpl3Only; + mainProgram = "redlib"; + maintainers = with lib.maintainers; [ soispha ]; + }; +} From bc54360b999bd059634d53a40db882bc969c2935 Mon Sep 17 00:00:00 2001 From: Soispha Date: Fri, 1 Mar 2024 21:27:18 +0100 Subject: [PATCH 2/2] nixos/tests: add redlib test using the libreddit module --- nixos/tests/redlib.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 nixos/tests/redlib.nix diff --git a/nixos/tests/redlib.nix b/nixos/tests/redlib.nix new file mode 100644 index 000000000000..e4bde25e30a6 --- /dev/null +++ b/nixos/tests/redlib.nix @@ -0,0 +1,20 @@ +import ./make-test-python.nix ({ lib, pkgs, ... }: { + name = "redlib"; + meta.maintainers = with lib.maintainers; [ soispha ]; + + nodes.machine = { + services.libreddit = { + package = pkgs.redlib; + enable = true; + # Test CAP_NET_BIND_SERVICE + port = 80; + }; + }; + + testScript = '' + machine.wait_for_unit("libreddit.service") + machine.wait_for_open_port(80) + # Query a page that does not require Internet access + machine.succeed("curl --fail http://localhost:80/settings") + ''; +})