From 3218ced8b89b47bffddef5c3488c69f09590806e Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com> Date: Fri, 21 Feb 2025 19:45:31 +0000 Subject: [PATCH 1/2] rathole: regenerate expired self-signed certs for tests Upstream dummy self-signed cert has expired and now tests fail: ``` Certificate: Data: Version: 3 (0x2) Serial Number: 1c:f6:27:75:97:e5:99:b0:d5:ff:7d:02:f8:11:d0:4a:23:6f:51:34 Signature Algorithm: sha256WithRSAEncryption Issuer: CN=MyOwnCA, C=US, L=San Fransisco Validity Not Before: Feb 15 05:04:49 2024 GMT Not After : Feb 5 05:04:49 2025 GMT ``` --- pkgs/by-name/ra/rathole/package.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/by-name/ra/rathole/package.nix b/pkgs/by-name/ra/rathole/package.nix index e58c023ee090..b9ddaf1f8671 100644 --- a/pkgs/by-name/ra/rathole/package.nix +++ b/pkgs/by-name/ra/rathole/package.nix @@ -33,6 +33,12 @@ rustPlatform.buildRustPackage { __darwinAllowLocalNetworking = true; + nativeCheckInputs = [ openssl ]; + preCheck = '' + patchShebangs examples/tls/create_self_signed_cert.sh + (cd examples/tls && chmod +x create_self_signed_cert.sh && ./create_self_signed_cert.sh) + ''; + passthru.tests = { inherit (nixosTests) rathole; }; From c2dd438510a523bfa53652d800a0d3c6142b59b8 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com> Date: Fri, 21 Feb 2025 20:18:29 +0000 Subject: [PATCH 2/2] rathole: get rid of vergen Fixes build on darwin. Drops legacy darwin SDK pattern (which is a no-op). --- .../ra/rathole/0001-no-more-vergen.patch | 22 +++++++++++ pkgs/by-name/ra/rathole/package.nix | 37 +++++++++++++++---- 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 pkgs/by-name/ra/rathole/0001-no-more-vergen.patch diff --git a/pkgs/by-name/ra/rathole/0001-no-more-vergen.patch b/pkgs/by-name/ra/rathole/0001-no-more-vergen.patch new file mode 100644 index 000000000000..9e6285cfb487 --- /dev/null +++ b/pkgs/by-name/ra/rathole/0001-no-more-vergen.patch @@ -0,0 +1,22 @@ +diff --git a/Cargo.toml b/Cargo.toml +index e7a944e..e6bae43 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -7,7 +7,6 @@ description = "A reverse proxy for NAT traversal" + license = "Apache-2.0" + repository = "https://github.com/rapiz1/rathole" + readme = "README.md" +-build = "build.rs" + include = ["src/**/*", "LICENSE", "README.md", "build.rs"] + + [features] +@@ -130,9 +129,4 @@ p12 = { version = "0.6.3", optional = true } + openssl = { version = "0.10", features = ["vendored"], optional = true } + + [build-dependencies] +-vergen = { version = "7.4.2", default-features = false, features = [ +- "build", +- "git", +- "cargo", +-] } + anyhow = "1.0" diff --git a/pkgs/by-name/ra/rathole/package.nix b/pkgs/by-name/ra/rathole/package.nix index b9ddaf1f8671..e7834483e8bc 100644 --- a/pkgs/by-name/ra/rathole/package.nix +++ b/pkgs/by-name/ra/rathole/package.nix @@ -3,13 +3,13 @@ stdenv, fetchFromGitHub, rustPlatform, + rustc, pkg-config, openssl, nixosTests, - darwin, }: -rustPlatform.buildRustPackage { +rustPlatform.buildRustPackage rec { pname = "rathole"; version = "0.5.0-unstable-2024-06-06"; @@ -20,16 +20,27 @@ rustPlatform.buildRustPackage { hash = "sha256-C0/G4JOZ4pTAvcKZhRHsGvlLlwAyWBQ0rMScLvaLSuA="; }; + # Get rid of git dependency on vergen. No reason to require libgit2-sys as + # well as libz-sys. Vendored c libraries for libgit2/zlib fail to build on + # darwin and using libs from nixpkgs seems excessive. + patches = [ + ./0001-no-more-vergen.patch + ]; + + # Build script is only needed for vergen and does nothing when not in a git + # repo. + postPatch = '' + rm build.rs + ''; + useFetchCargoVendor = true; cargoHash = "sha256-IgPDe8kuWzJ6nF2DceUbN7fw0eGkoYhu1IGMdlSMFos="; nativeBuildInputs = [ pkg-config ]; - buildInputs = - [ - openssl - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ CoreServices ]); + buildInputs = [ + openssl + ]; __darwinAllowLocalNetworking = true; @@ -39,6 +50,18 @@ rustPlatform.buildRustPackage { (cd examples/tls && chmod +x create_self_signed_cert.sh && ./create_self_signed_cert.sh) ''; + env = { + VERGEN_BUILD_TIMESTAMP = "0"; + VERGEN_BUILD_SEMVER = version; + VERGEN_GIT_COMMIT_TIMESTAMP = "0"; + VERGEN_GIT_BRANCH = "main"; + VERGEN_RUSTC_SEMVER = rustc.version; + VERGEN_RUSTC_CHANNEL = "stable"; + VERGEN_CARGO_PROFILE = "release"; + VERGEN_CARGO_FEATURES = ""; + VERGEN_CARGO_TARGET_TRIPLE = "${stdenv.hostPlatform.rust.rustcTarget}"; + }; + passthru.tests = { inherit (nixosTests) rathole; };