33 stdenv ,
44 fetchFromGitHub ,
55 rustPlatform ,
6+ rustc ,
67 pkg-config ,
78 openssl ,
89 nixosTests ,
9- darwin ,
1010} :
1111
12- rustPlatform . buildRustPackage {
12+ rustPlatform . buildRustPackage rec {
1313 pname = "rathole" ;
1414 version = "0.5.0-unstable-2024-06-06" ;
1515
@@ -20,19 +20,48 @@ rustPlatform.buildRustPackage {
2020 hash = "sha256-C0/G4JOZ4pTAvcKZhRHsGvlLlwAyWBQ0rMScLvaLSuA=" ;
2121 } ;
2222
23+ # Get rid of git dependency on vergen. No reason to require libgit2-sys as
24+ # well as libz-sys. Vendored c libraries for libgit2/zlib fail to build on
25+ # darwin and using libs from nixpkgs seems excessive.
26+ patches = [
27+ ./0001-no-more-vergen.patch
28+ ] ;
29+
30+ # Build script is only needed for vergen and does nothing when not in a git
31+ # repo.
32+ postPatch = ''
33+ rm build.rs
34+ '' ;
35+
2336 useFetchCargoVendor = true ;
2437 cargoHash = "sha256-IgPDe8kuWzJ6nF2DceUbN7fw0eGkoYhu1IGMdlSMFos=" ;
2538
2639 nativeBuildInputs = [ pkg-config ] ;
2740
28- buildInputs =
29- [
30- openssl
31- ]
32- ++ lib . optionals stdenv . hostPlatform . isDarwin ( with darwin . apple_sdk . frameworks ; [ CoreServices ] ) ;
41+ buildInputs = [
42+ openssl
43+ ] ;
3344
3445 __darwinAllowLocalNetworking = true ;
3546
47+ nativeCheckInputs = [ openssl ] ;
48+ preCheck = ''
49+ patchShebangs examples/tls/create_self_signed_cert.sh
50+ (cd examples/tls && chmod +x create_self_signed_cert.sh && ./create_self_signed_cert.sh)
51+ '' ;
52+
53+ env = {
54+ VERGEN_BUILD_TIMESTAMP = "0" ;
55+ VERGEN_BUILD_SEMVER = version ;
56+ VERGEN_GIT_COMMIT_TIMESTAMP = "0" ;
57+ VERGEN_GIT_BRANCH = "main" ;
58+ VERGEN_RUSTC_SEMVER = rustc . version ;
59+ VERGEN_RUSTC_CHANNEL = "stable" ;
60+ VERGEN_CARGO_PROFILE = "release" ;
61+ VERGEN_CARGO_FEATURES = "" ;
62+ VERGEN_CARGO_TARGET_TRIPLE = "${ stdenv . hostPlatform . rust . rustcTarget } " ;
63+ } ;
64+
3665 passthru . tests = {
3766 inherit ( nixosTests ) rathole ;
3867 } ;
0 commit comments