Unverified Commit 6d6df828 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

rathole: fix test failures due to expired certs, fix darwin build (#384040)

parents 0c4bc741 c2dd4385
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
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"
+36 −7
Original line number Diff line number Diff line
@@ -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,19 +20,48 @@ 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 =
    [
  buildInputs = [
    openssl
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ CoreServices ]);
  ];

  __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)
  '';

  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;
  };