Unverified Commit e1265248 authored by Maciej Krüger's avatar Maciej Krüger Committed by GitHub
Browse files

tribler: 7.14.0 -> 8.2.3 (#388333)

parents 8c5f8032 60ce2a62
Loading
Loading
Loading
Loading
+129 −105
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchurl,
  fetchPypi,
  python311,
  python312,
  makeWrapper,
  libtorrent-rasterbar-1_2_x,
  qt5,
  nix-update-script,
  boost186,
  fetchFromGitHub,
  rustPlatform,
  buildNpmPackage,
  nodejs_24,
  wrapGAppsHook3,
  libappindicator-gtk3,
}:

let
  # libtorrent-rasterbar-1_2_x requires python311 and boost 1.86
  python3 = python311.override {
    packageOverrides = final: prev: {
      boost = boost186;
    };
  version = "8.2.3";
  python3 = python312;
  nodejs = nodejs_24;

  src = fetchFromGitHub {
    owner = "tribler";
    repo = "Tribler";
    tag = "v${version}";
    hash = "sha256-yThl3HhPtwi/pK5Rcr2ClVLY8uCnIyfvdc53A8gjKDg=";
  };
  libtorrent = (python3.pkgs.toPythonModule (libtorrent-rasterbar-1_2_x)).python;
in
stdenv.mkDerivation (finalAttrs: {
  pname = "tribler";
  version = "7.14.0";

  src = fetchurl {
    url = "https://github.com/Tribler/tribler/releases/download/v${finalAttrs.version}/Tribler-${finalAttrs.version}.tar.xz";
    hash = "sha256-fQJOs9P4y71De/+svmD7YZ4+tm/bC3rspm7SbOHlSR4=";
  tribler-webui = buildNpmPackage {
    inherit nodejs version;
    pname = "tribler-webui";
    src = "${src}/src/tribler/ui";
    npmDepsHash = "sha256-bgRwhqP6/NMPFbZks31IZtVGV9wzFFU6qSgyLvdarlY=";

    # The prepack script runs the build script, which we'd rather do in the build phase.
    npmPackFlags = [ "--ignore-scripts" ];

    NODE_OPTIONS = "--openssl-legacy-provider";

    dontNpmBuild = true;
    dontNpmInstall = true;

    installPhase = ''
      mkdir -pv $out
      cp -prvd ./* $out/
      cd $out
      npm install
      npm run build
    '';
  };

  patches = [
    ./startupwmclass.patch
  ];
in

python3.pkgs.buildPythonApplication {
  inherit version src;
  name = "tribler";
  pyproject = true;

  nativeBuildInputs = [
    python3.pkgs.wrapPython
    makeWrapper
    # we had a "copy" of this in tribler's makeWrapper
    # but it went out of date and broke, so please just use it directly
    qt5.wrapQtAppsHook
  build-system = with python3.pkgs; [
    setuptools
  ];

  buildInputs = [ python3.pkgs.python ];

  pythonPath = [
    libtorrent
  ]
  ++ (with python3.pkgs; [
    # requirements-core.txt
    aiohttp
    aiohttp-apispec
    anyio
    chardet
  dependencies = with python3.pkgs; [
    # requirements.txt
    bitarray
    configobj
    cryptography
    decorator
    faker
    libnacl
    pyipv8
    ipv8-rust-tunnels
    libtorrent-rasterbar
    lz4
    marshmallow
    netifaces
    networkx
    pony
    psutil
    pyasn1
    pydantic_1
    pyopenssl
    pyyaml
    sentry-sdk
    service-identity
    yappi
    yarl
    bitarray
    filelock
    (pyipv8.overrideAttrs (p: rec {
      version = "2.10.0";
      src = fetchPypi {
        inherit (p) pname;
        inherit version;
        hash = "sha256-yxiXBxBiPokequm+vjsHIoG9kQnRnbsOx3mYOd8nmiU=";
      };
    }))
    file-read-backwards
    brotli
    human-readable
    # requirements.txt
    pillow
    pyqt5
    pyqt5-sip
    pyqtgraph
    pyqtwebengine
  ]);
    pony
    pystray
  ];

  installPhase = ''
    mkdir -pv $out
    # Nasty hack; call wrapPythonPrograms to set program_PYTHONPATH.
    wrapPythonPrograms
    cp -prvd ./* $out/
    makeWrapper ${python3.pkgs.python}/bin/python $out/bin/tribler \
        --set _TRIBLERPATH "$out/src" \
        --set PYTHONPATH $out/src/tribler-core:$out/src/tribler-common:$out/src/tribler-gui:$program_PYTHONPATH \
        --set NO_AT_BRIDGE 1 \
        --chdir "$out/src" \
        --add-flags "-O $out/src/run_tribler.py"

    mkdir -p $out/share/applications $out/share/icons
    cp $out/build/debian/tribler/usr/share/applications/org.tribler.Tribler.desktop $out/share/applications/
    cp $out/build/debian/tribler/usr/share/pixmaps/tribler_big.xpm $out/share/icons/tribler.xpm
    mkdir -p $out/share/copyright/tribler
    mv $out/LICENSE $out/share/copyright/tribler
  buildInputs = with python3.pkgs; [
    # setup.py requirements
    pygobject3
    setuptools
    # sphinx requirements
    sphinxHook
    sphinx
    sphinx-autoapi
    sphinx-rtd-theme
    astroid
    # tray icon deps
    wrapGAppsHook3
    libappindicator-gtk3
    # test phase requirements
    pytestCheckHook

  ];

  outputs = [
    "out"
  ];

  buildPhase = ''
          # fix the entrypoint
          substituteInPlace build/setup.py --replace-fail '"tribler=tribler.run:main"' '"tribler=tribler.run:main_sync"'
          substituteInPlace src/run_tribler.py --replace-fail 'if __name__ == "__main__":' 'def main_sync():'

          # copy the built webui
          rm -r src/tribler/ui
          ln -s ${tribler-webui} src/tribler/ui

          # build the docs
    # FIXME:      make doc SPHINXBUILD=${lib.getExe' python3.pkgs.sphinx "sphinx-build"}

          # build the wheel
          substituteInPlace build/win/build.py --replace-fail "if {'setup.py', 'bdist_wheel'}.issubset(sys.argv):" "if True:"
          export GITHUB_TAG=v${version}
          python3 build/debian/update_metainfo.py
          python3 build/setup.py bdist_wheel

        runHook pytestCheckHook

          # build the docs
        runHook sphinxHook
  '';

  shellHook = ''
    wrapPythonPrograms || true
    export QT_QPA_PLATFORM_PLUGIN_PATH=$(echo ${qt5.qtbase.bin}/lib/qt-*/plugins/platforms)
    export PYTHONPATH=./tribler-core:./tribler-common:./tribler-gui:$program_PYTHONPATH
    export QT_PLUGIN_PATH="${qt5.qtsvg.bin}/${qt5.qtbase.qtPluginPrefix}"
  postInstall = ''
    ln -s ${tribler-webui} $out/lib/python3.12/site-packages/tribler/ui
  '';

  preFixup = ''
    gappsWrapperArgs+=(
      --prefix GI_TYPELIB_PATH : "${lib.makeSearchPath "lib/girepository-1.0" [ libappindicator-gtk3 ]}"
    )
  '';

  postFixup = ''
    runHook wrapGAppsHook3
  '';

  disabledTests = [
    "test_request_for_version"
    "test_establish_connection"
    "test_tracker_test_error_resolve"
    "test_get_default_fallback"
    "test_get_default_fallback_half_tree"
    "test_get_set_explicit"
  ];

  disabledTestPaths = [
  ];

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

  meta = {
    description = "Decentralised P2P filesharing client based on the Bittorrent protocol";
    description = "Decentralized P2P filesharing client based on the Bittorrent protocol";
    mainProgram = "tribler";
    homepage = "https://www.tribler.org/";
    changelog = "https://github.com/Tribler/tribler/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.lgpl21Plus;
    changelog = "https://github.com/Tribler/tribler/releases/tag/v${version}";
    license = lib.licenses.gpl3;
    maintainers = with lib.maintainers; [
      xvapx

      mkg20001
      mlaradji
      xvapx
    ];
    platforms = lib.platforms.linux;
  };
})
}
+0 −9
Original line number Diff line number Diff line
diff --git a/build/debian/tribler/usr/share/applications/org.tribler.Tribler.desktop b/build/debian/tribler/usr/share/applications/org.tribler.Tribler.desktop
index b0472a18d..0e0be14f3 100644
--- a/build/debian/tribler/usr/share/applications/org.tribler.Tribler.desktop
+++ b/build/debian/tribler/usr/share/applications/org.tribler.Tribler.desktop
@@ -7,3 +7,4 @@ Terminal=false
 Type=Application
 Categories=Application;Network;P2P
 MimeType=x-scheme-handler/ppsp;x-scheme-handler/tswift;x-scheme-handler/magnet;application/x-bittorrent
+StartupWMClass=Tribler
+9 −5
Original line number Diff line number Diff line
@@ -27,11 +27,15 @@ buildPythonPackage rec {
    hash = "sha256-C+/M25oCLTNGGEUj2EyXn3UjcvPvDYFmmUW8IOoF1uU=";
  };

  doCheck = false;

  /*
    postPatch = ''
      substituteInPlace tests/conftest.py \
        --replace-fail 'aiohttp_app(loop,' 'aiohttp_app(event_loop,' \
        --replace-fail 'return loop.run_until_complete' 'return event_loop.run_until_complete'
    '';
  */

  build-system = [ setuptools ];

+35 −0
Original line number Diff line number Diff line
{
  lib,
  rustPlatform,
  fetchPypi,
  buildPythonPackage,
}:

buildPythonPackage rec {
  pname = "ipv8-rust-tunnels";
  version = "0.1.33";
  pyproject = true;

  src = fetchPypi {
    inherit version;
    pname = "ipv8_rust_tunnels";
    hash = "sha256-LwQL/u+h6mwCo207OxSk9YKxuLuxXQhh07rSWrNFh7w=";
  };

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit pname version src;
    hash = "sha256-NwYLez9NFgS0GBXrcNrKJKV+s4HIHM8jHXfmkgya03M=";
  };

  nativeBuildInputs = with rustPlatform; [
    cargoSetupHook
    maturinBuildHook
  ];

  meta = with lib; {
    description = "A set of performance enhancements to the TunnelCommunity, the anonymization layer used in IPv8 and Tribler";
    homepage = "https://github.com/Tribler/ipv8-rust-tunnels";
    license = licenses.lgpl3Only;
    maintainers = with maintainers; [ mlaradji ];
  };
}
+7 −4
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  lib,
  fetchPypi,
  buildPythonPackage,
  fetchFromGitHub,
  cryptography,
  libnacl,
  aiohttp,
@@ -16,12 +17,14 @@

buildPythonPackage rec {
  pname = "pyipv8";
  version = "3.0.0";
  version = "3.0.2197-unstable-2025-07-29";
  format = "setuptools";

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-e8HoKKA1s93LbmvHs7gJqmCcuZZ9REenBwxKJFR6wjM=";
  src = fetchFromGitHub {
    owner = "tribler";
    repo = "py-ipv8";
    rev = "db39b85f4c28880dee24d1b59d8eae8ca8b9c03d";
    hash = "sha256-VIcBPzpK8Cdaz/dRp9QK/MtK41jm8rs/pxnLS716FNM=";
  };

  propagatedBuildInputs = [
Loading