torsocks: fix build on darwin

+66 -14
+33
pkgs/tools/security/tor/torsocks-gethostbyaddr-darwin.patch
··· 1 + diff --git a/tests/test_dns.c b/tests/test_dns.c 2 + index 7e07663..acf095c 100644 3 + --- a/tests/test_dns.c 4 + +++ b/tests/test_dns.c 5 + @@ -76,6 +76,8 @@ static void test_gethostbyname(const struct test_host *host) 6 + return; 7 + } 8 + 9 + +#ifdef __linux__ 10 + + 11 + static void test_gethostbyaddr_r_failed(void) 12 + { 13 + int result; 14 + @@ -129,6 +131,8 @@ static void test_gethostbyaddr_r(const struct test_host *host) 15 + ok(1, "Resolved address"); 16 + } 17 + 18 + +#endif 19 + + 20 + static void test_gethostbyaddr(const struct test_host *host) 21 + { 22 + struct hostent *he; 23 + @@ -199,8 +203,10 @@ int main(int argc, char **argv) 24 + test_getaddrinfo(&tor_check); 25 + test_gethostbyname(&tor_dir_auth1); 26 + test_gethostbyaddr(&tor_dir_auth2); 27 + +#ifdef __linux__ 28 + test_gethostbyaddr_r(&tor_dir_auth2); 29 + test_gethostbyaddr_r_failed(); 30 + +#endif 31 + test_getaddrinfo(&tor_localhost); 32 + 33 + end:
+33 -14
pkgs/tools/security/tor/torsocks.nix
··· 1 - { lib, stdenv, fetchgit, fetchurl, autoreconfHook, libcap }: 1 + { lib 2 + , stdenv 3 + , fetchFromGitLab 4 + , fetchpatch 5 + , autoreconfHook 6 + , libcap 7 + }: 2 8 3 9 stdenv.mkDerivation rec { 4 10 pname = "torsocks"; 5 - version = "2.3.0"; 11 + version = "2.4.0"; 6 12 7 - src = fetchgit { 8 - url = "https://git.torproject.org/torsocks.git"; 9 - rev = "refs/tags/v${version}"; 10 - sha256 = "0x0wpcigf22sjxg7bm0xzqihmsrz51hl4v8xf91qi4qnmr4ny1hb"; 13 + src = fetchFromGitLab { 14 + domain = "gitlab.torproject.org"; 15 + group = "tpo"; 16 + owner = "core"; 17 + repo = "torsocks"; 18 + rev = "v${version}"; 19 + sha256 = "sha256-ocJkoF9LMLC84ukFrm5pzjp/1gaXqDz8lzr9TdG+f88="; 11 20 }; 12 21 13 - nativeBuildInputs = [ autoreconfHook ]; 14 - 15 - patches = lib.optional stdenv.isDarwin 16 - (fetchurl { 17 - url = "https://trac.torproject.org/projects/tor/raw-attachment/ticket/28538/0001-Fix-macros-for-accept4-2.patch"; 18 - sha256 = "97881f0b59b3512acc4acb58a0d6dfc840d7633ead2f400fad70dda9b2ba30b0"; 19 - }); 22 + patches = [ 23 + # fix compatibility with C99 24 + # https://gitlab.torproject.org/tpo/core/torsocks/-/merge_requests/9 25 + (fetchpatch { 26 + url = "https://gitlab.torproject.org/tpo/core/torsocks/-/commit/1171bf2fd4e7a0cab02cf5fca59090b65af9cd29.patch"; 27 + hash = "sha256-qu5/0fy72+02QI0cVE/6YrR1kPuJxsZfG8XeODqVOPY="; 28 + }) 29 + # tsocks_libc_accept4 only exists on Linux, use tsocks_libc_accept on other platforms 30 + (fetchpatch { 31 + url = "https://gitlab.torproject.org/tpo/core/torsocks/uploads/eeec9833512850306a42a0890d283d77/0001-Fix-macros-for-accept4-2.patch"; 32 + hash = "sha256-XWi8+UFB8XgBFSl5QDJ+hLu/dH4CvAwYbeZz7KB10Bs="; 33 + }) 34 + # no gethostbyaddr_r on darwin 35 + ./torsocks-gethostbyaddr-darwin.patch 36 + ]; 20 37 21 38 postPatch = '' 22 39 # Patch torify_app() ··· 29 46 src/bin/torsocks.in 30 47 ''; 31 48 49 + nativeBuildInputs = [ autoreconfHook ]; 50 + 32 51 doInstallCheck = true; 33 52 installCheckTarget = "check-recursive"; 34 53 35 54 meta = { 36 55 description = "Wrapper to safely torify applications"; 37 - homepage = "https://github.com/dgoulet/torsocks"; 56 + homepage = "https://gitlab.torproject.org/tpo/core/torsocks"; 38 57 license = lib.licenses.gpl2; 39 58 platforms = lib.platforms.unix; 40 59 maintainers = with lib.maintainers; [ thoughtpolice ];