base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12 (#356361)
[NixPkgs.git] / pkgs / tools / security / tor / torsocks.nix
blob8b09bfc3bf9b6b797217152db24f60bc4cc7921f
1 { lib
2 , stdenv
3 , fetchFromGitLab
4 , fetchpatch
5 , autoreconfHook
6 , libcap
7 }:
9 stdenv.mkDerivation rec {
10   pname = "torsocks";
11   version = "2.4.0";
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=";
20   };
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   ];
38   postPatch = ''
39     # Patch torify_app()
40     sed -i \
41       -e 's,\(local app_path\)=`which $1`,\1=`type -P $1`,' \
42       src/bin/torsocks.in
43   '' + lib.optionalString stdenv.hostPlatform.isLinux ''
44     sed -i \
45       -e 's,\(local getcap\)=.*,\1=${libcap}/bin/getcap,' \
46       src/bin/torsocks.in
47   '';
49   nativeBuildInputs = [ autoreconfHook ];
51   doInstallCheck = true;
52   installCheckTarget = "check-recursive";
54   meta = {
55     description      = "Wrapper to safely torify applications";
56     mainProgram = "torsocks";
57     homepage         = "https://gitlab.torproject.org/tpo/core/torsocks";
58     license          = lib.licenses.gpl2Plus;
59     platforms        = lib.platforms.unix;
60     maintainers      = with lib.maintainers; [ thoughtpolice ];
61   };