2024-02-09 16:23:33 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitLab
|
|
|
|
, fetchpatch
|
|
|
|
, autoreconfHook
|
|
|
|
, libcap
|
|
|
|
}:
|
2014-12-06 04:32:56 +00:00
|
|
|
|
2010-10-01 02:38:03 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "torsocks";
|
2024-02-09 16:23:33 +00:00
|
|
|
version = "2.4.0";
|
2014-12-06 04:32:56 +00:00
|
|
|
|
2024-02-09 16:23:33 +00:00
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "gitlab.torproject.org";
|
|
|
|
group = "tpo";
|
|
|
|
owner = "core";
|
|
|
|
repo = "torsocks";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "sha256-ocJkoF9LMLC84ukFrm5pzjp/1gaXqDz8lzr9TdG+f88=";
|
2010-10-01 02:38:03 +00:00
|
|
|
};
|
|
|
|
|
2024-02-09 16:23:33 +00:00
|
|
|
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
|
|
|
|
];
|
2020-05-10 21:52:15 +00:00
|
|
|
|
2016-12-04 17:58:12 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Patch torify_app()
|
|
|
|
sed -i \
|
|
|
|
-e 's,\(local app_path\)=`which $1`,\1=`type -P $1`,' \
|
2020-05-10 21:52:15 +00:00
|
|
|
src/bin/torsocks.in
|
2021-01-15 09:19:50 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
|
2020-05-10 21:52:15 +00:00
|
|
|
sed -i \
|
2016-12-04 17:58:12 +00:00
|
|
|
-e 's,\(local getcap\)=.*,\1=${libcap}/bin/getcap,' \
|
|
|
|
src/bin/torsocks.in
|
2014-12-06 04:32:56 +00:00
|
|
|
'';
|
|
|
|
|
2024-02-09 16:23:33 +00:00
|
|
|
nativeBuildInputs = [ autoreconfHook ];
|
|
|
|
|
2016-12-04 18:31:27 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckTarget = "check-recursive";
|
|
|
|
|
2010-10-01 02:38:03 +00:00
|
|
|
meta = {
|
2014-12-06 04:32:56 +00:00
|
|
|
description = "Wrapper to safely torify applications";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "torsocks";
|
2024-02-09 16:23:33 +00:00
|
|
|
homepage = "https://gitlab.torproject.org/tpo/core/torsocks";
|
2024-04-26 11:35:31 +00:00
|
|
|
license = lib.licenses.gpl2Plus;
|
2021-01-15 09:19:50 +00:00
|
|
|
platforms = lib.platforms.unix;
|
2021-12-18 09:25:46 +00:00
|
|
|
maintainers = with lib.maintainers; [ thoughtpolice ];
|
2010-10-01 02:38:03 +00:00
|
|
|
};
|
|
|
|
}
|