about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/security/tor/torsocks.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/security/tor/torsocks.nix')
-rw-r--r--nixpkgs/pkgs/tools/security/tor/torsocks.nix47
1 files changed, 33 insertions, 14 deletions
diff --git a/nixpkgs/pkgs/tools/security/tor/torsocks.nix b/nixpkgs/pkgs/tools/security/tor/torsocks.nix
index 16eeca0ffad7..6c5be8fcc7bd 100644
--- a/nixpkgs/pkgs/tools/security/tor/torsocks.nix
+++ b/nixpkgs/pkgs/tools/security/tor/torsocks.nix
@@ -1,22 +1,39 @@
-{ lib, stdenv, fetchgit, fetchurl, autoreconfHook, libcap }:
+{ lib
+, stdenv
+, fetchFromGitLab
+, fetchpatch
+, autoreconfHook
+, libcap
+}:
 
 stdenv.mkDerivation rec {
   pname = "torsocks";
-  version = "2.3.0";
+  version = "2.4.0";
 
-  src = fetchgit {
-    url    = "https://git.torproject.org/torsocks.git";
-    rev    = "refs/tags/v${version}";
-    sha256 = "0x0wpcigf22sjxg7bm0xzqihmsrz51hl4v8xf91qi4qnmr4ny1hb";
+  src = fetchFromGitLab {
+    domain = "gitlab.torproject.org";
+    group = "tpo";
+    owner = "core";
+    repo = "torsocks";
+    rev = "v${version}";
+    sha256 = "sha256-ocJkoF9LMLC84ukFrm5pzjp/1gaXqDz8lzr9TdG+f88=";
   };
 
-  nativeBuildInputs = [ autoreconfHook ];
-
-  patches = lib.optional stdenv.isDarwin
-    (fetchurl {
-       url = "https://trac.torproject.org/projects/tor/raw-attachment/ticket/28538/0001-Fix-macros-for-accept4-2.patch";
-       sha256 = "97881f0b59b3512acc4acb58a0d6dfc840d7633ead2f400fad70dda9b2ba30b0";
-     });
+  patches = [
+    # fix compatibility with C99
+    # https://gitlab.torproject.org/tpo/core/torsocks/-/merge_requests/9
+    (fetchpatch {
+      url = "https://gitlab.torproject.org/tpo/core/torsocks/-/commit/1171bf2fd4e7a0cab02cf5fca59090b65af9cd29.patch";
+      hash = "sha256-qu5/0fy72+02QI0cVE/6YrR1kPuJxsZfG8XeODqVOPY=";
+    })
+    # tsocks_libc_accept4 only exists on Linux, use tsocks_libc_accept on other platforms
+    (fetchpatch {
+      url = "https://gitlab.torproject.org/tpo/core/torsocks/uploads/eeec9833512850306a42a0890d283d77/0001-Fix-macros-for-accept4-2.patch";
+      hash = "sha256-XWi8+UFB8XgBFSl5QDJ+hLu/dH4CvAwYbeZz7KB10Bs=";
+    })
+    # no gethostbyaddr_r on darwin
+    ./torsocks-gethostbyaddr-darwin.patch
+  ];
 
   postPatch = ''
     # Patch torify_app()
@@ -29,12 +46,14 @@ stdenv.mkDerivation rec {
       src/bin/torsocks.in
   '';
 
+  nativeBuildInputs = [ autoreconfHook ];
+
   doInstallCheck = true;
   installCheckTarget = "check-recursive";
 
   meta = {
     description      = "Wrapper to safely torify applications";
-    homepage         = "https://github.com/dgoulet/torsocks";
+    homepage         = "https://gitlab.torproject.org/tpo/core/torsocks";
     license          = lib.licenses.gpl2;
     platforms        = lib.platforms.unix;
     maintainers      = with lib.maintainers; [ thoughtpolice ];