Commit bb1e3933 authored by Saterfield990's avatar Saterfield990
Browse files

torsocks: 2.4.0 -> 2.5.0

parent e80c0626
Loading
Loading
Loading
Loading
+19 −27
Original line number Diff line number Diff line
@@ -5,28 +5,26 @@
  fetchpatch,
  autoreconfHook,
  libcap,
  nix-update-script,
  versionCheckHook,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "torsocks";
  version = "2.4.0";
  version = "2.5.0";

  src = fetchFromGitLab {
    domain = "gitlab.torproject.org";
    group = "tpo";
    owner = "core";
    repo = "torsocks";
    rev = "v${version}";
    sha256 = "sha256-ocJkoF9LMLC84ukFrm5pzjp/1gaXqDz8lzr9TdG+f88=";
    tag = "v${finalAttrs.version}";
    hash = "sha256-um5D6d/fzKynfa1kA/VbdnKvAlZ7jQs+pmOgWQMpwgM=";
  };

  nativeBuildInputs = [ autoreconfHook ];

  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";
@@ -36,30 +34,24 @@ stdenv.mkDerivation rec {
    ./torsocks-gethostbyaddr-darwin.patch
  ];

  postPatch =
    ''
      # Patch torify_app()
      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
  postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
    substituteInPlace src/bin/torsocks.in --replace-fail \
    '"$(PATH="$PATH:/usr/sbin:/sbin" command -v getcap)"' '${libcap}/bin/getcap'
  '';

  nativeBuildInputs = [ autoreconfHook ];

  doInstallCheck = true;
  installCheckTarget = "check-recursive";
  nativeInstallCheckInputs = [ versionCheckHook ];

  passthru.updateScript = nix-update-script { };

  meta = {
    changelog = "https://gitlab.torproject.org/tpo/core/torsocks/-/releases/v${finalAttrs.version}";
    description = "Wrapper to safely torify applications";
    mainProgram = "torsocks";
    homepage = "https://gitlab.torproject.org/tpo/core/torsocks";
    license = lib.licenses.gpl2Plus;
    platforms = lib.platforms.unix;
    mainProgram = "torsocks";
    maintainers = with lib.maintainers; [ thoughtpolice ];
    platforms = lib.platforms.unix;
  };
}
})