tor{,socks}: move to by-name; 2.4.0 -> 2.5.0; improve (#419239)

This commit is contained in:
Philip Taron 2025-07-15 11:06:13 -07:00 committed by GitHub
commit 734f17ad1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 37 additions and 44 deletions

View File

@ -15,6 +15,7 @@
scrypt, scrypt,
nixosTests, nixosTests,
writeShellScript, writeShellScript,
versionCheckHook,
# for update.nix # for update.nix
writeScript, writeScript,
@ -27,6 +28,7 @@
gnused, gnused,
nix, nix,
}: }:
let let
tor-client-auth-gen = writeShellScript "tor-client-auth-gen" '' tor-client-auth-gen = writeShellScript "tor-client-auth-gen" ''
PATH="${ PATH="${
@ -48,13 +50,14 @@ let
base64 -d | tail --bytes=32 | base32 | tr -d = base64 -d | tail --bytes=32 | base32 | tr -d =
''; '';
in in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "tor"; pname = "tor";
version = "0.4.8.17"; version = "0.4.8.17";
src = fetchurl { src = fetchurl {
url = "https://dist.torproject.org/${pname}-${version}.tar.gz"; url = "https://dist.torproject.org/tor-${finalAttrs.version}.tar.gz";
sha256 = "sha256-ebRyXh1LiHueaP0JsNIkN3fVzjzUceU4WDvPb52M21Y="; hash = "sha256-ebRyXh1LiHueaP0JsNIkN3fVzjzUceU4WDvPb52M21Y=";
}; };
outputs = [ outputs = [
@ -63,6 +66,7 @@ stdenv.mkDerivation rec {
]; ];
nativeBuildInputs = [ pkg-config ]; nativeBuildInputs = [ pkg-config ];
buildInputs = buildInputs =
[ [
libevent libevent
@ -98,8 +102,7 @@ stdenv.mkDerivation rec {
postPatch = '' postPatch = ''
substituteInPlace contrib/client-tools/torify \ substituteInPlace contrib/client-tools/torify \
--replace 'pathfind torsocks' true \ --replace-fail 'exec torsocks' 'exec ${torsocks}/bin/torsocks'
--replace 'exec torsocks' 'exec ${torsocks}/bin/torsocks'
patchShebangs ./scripts/maint/checkShellScripts.sh patchShebangs ./scripts/maint/checkShellScripts.sh
''; '';
@ -117,6 +120,10 @@ stdenv.mkDerivation rec {
ln -s ${tor-client-auth-gen} $out/bin/tor-client-auth-gen ln -s ${tor-client-auth-gen} $out/bin/tor-client-auth-gen
''; '';
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
passthru = { passthru = {
tests.tor = nixosTests.tor; tests.tor = nixosTests.tor;
updateScript = import ./update.nix { updateScript = import ./update.nix {
@ -135,10 +142,9 @@ stdenv.mkDerivation rec {
}; };
}; };
meta = with lib; { meta = {
homepage = "https://www.torproject.org/"; homepage = "https://www.torproject.org/";
description = "Anonymizing overlay network"; description = "Anonymizing overlay network";
longDescription = '' longDescription = ''
Tor helps improve your privacy by bouncing your communications around a Tor helps improve your privacy by bouncing your communications around a
network of relays run by volunteers all around the world: it makes it network of relays run by volunteers all around the world: it makes it
@ -148,17 +154,16 @@ stdenv.mkDerivation rec {
instant messaging clients, remote login, and other applications based on instant messaging clients, remote login, and other applications based on
the TCP protocol. the TCP protocol.
''; '';
license = with lib.licenses; [
license = with licenses; [
bsd3 bsd3
gpl3Only gpl3Only
]; ];
mainProgram = "tor";
maintainers = with maintainers; [ maintainers = with lib.maintainers; [
thoughtpolice thoughtpolice
joachifm joachifm
prusnak prusnak
]; ];
platforms = platforms.unix; platforms = lib.platforms.unix;
}; };
} })

View File

@ -5,28 +5,26 @@
fetchpatch, fetchpatch,
autoreconfHook, autoreconfHook,
libcap, libcap,
nix-update-script,
versionCheckHook,
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "torsocks"; pname = "torsocks";
version = "2.4.0"; version = "2.5.0";
src = fetchFromGitLab { src = fetchFromGitLab {
domain = "gitlab.torproject.org"; domain = "gitlab.torproject.org";
group = "tpo"; group = "tpo";
owner = "core"; owner = "core";
repo = "torsocks"; repo = "torsocks";
rev = "v${version}"; tag = "v${finalAttrs.version}";
sha256 = "sha256-ocJkoF9LMLC84ukFrm5pzjp/1gaXqDz8lzr9TdG+f88="; hash = "sha256-um5D6d/fzKynfa1kA/VbdnKvAlZ7jQs+pmOgWQMpwgM=";
}; };
nativeBuildInputs = [ autoreconfHook ];
patches = [ 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 # tsocks_libc_accept4 only exists on Linux, use tsocks_libc_accept on other platforms
(fetchpatch { (fetchpatch {
url = "https://gitlab.torproject.org/tpo/core/torsocks/uploads/eeec9833512850306a42a0890d283d77/0001-Fix-macros-for-accept4-2.patch"; url = "https://gitlab.torproject.org/tpo/core/torsocks/uploads/eeec9833512850306a42a0890d283d77/0001-Fix-macros-for-accept4-2.patch";
@ -36,30 +34,24 @@ stdenv.mkDerivation rec {
./torsocks-gethostbyaddr-darwin.patch ./torsocks-gethostbyaddr-darwin.patch
]; ];
postPatch = postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
'' substituteInPlace src/bin/torsocks.in --replace-fail \
# Patch torify_app() '"$(PATH="$PATH:/usr/sbin:/sbin" command -v getcap)"' '${libcap}/bin/getcap'
sed -i \ '';
-e 's,\(local app_path\)=`which $1`,\1=`type -P $1`,' \
src/bin/torsocks.in
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
sed -i \
-e 's,\(local getcap\)=.*,\1=${libcap}/bin/getcap,' \
src/bin/torsocks.in
'';
nativeBuildInputs = [ autoreconfHook ];
doInstallCheck = true; doInstallCheck = true;
installCheckTarget = "check-recursive"; installCheckTarget = "check-recursive";
nativeInstallCheckInputs = [ versionCheckHook ];
passthru.updateScript = nix-update-script { };
meta = { meta = {
changelog = "https://gitlab.torproject.org/tpo/core/torsocks/-/releases/v${finalAttrs.version}";
description = "Wrapper to safely torify applications"; description = "Wrapper to safely torify applications";
mainProgram = "torsocks";
homepage = "https://gitlab.torproject.org/tpo/core/torsocks"; homepage = "https://gitlab.torproject.org/tpo/core/torsocks";
license = lib.licenses.gpl2Plus; license = lib.licenses.gpl2Plus;
platforms = lib.platforms.unix; mainProgram = "torsocks";
maintainers = with lib.maintainers; [ thoughtpolice ]; maintainers = with lib.maintainers; [ thoughtpolice ];
platforms = lib.platforms.unix;
}; };
} })

View File

@ -4483,10 +4483,6 @@ with pkgs;
} }
); );
tor = callPackage ../tools/security/tor { };
torsocks = callPackage ../tools/security/tor/torsocks.nix { };
trackma-curses = trackma.override { withCurses = true; }; trackma-curses = trackma.override { withCurses = true; };
trackma-gtk = trackma.override { withGTK = true; }; trackma-gtk = trackma.override { withGTK = true; };