Commit b645bf2f authored by Pavel Sobolev's avatar Pavel Sobolev Committed by Peter Hoeg
Browse files

qbittorrent: 4.5.5 -> 4.6.0 + other changes

Other changes:
- Refactor
- Switch to CMake
- Build with Qt6 by default and add a separate derivation for Qt5
parent cedd2ce2
Loading
Loading
Loading
Loading
+71 −37
Original line number Diff line number Diff line
{ mkDerivation, lib, stdenv, fetchFromGitHub, pkg-config
, boost, libtorrent-rasterbar, qtbase, qttools, qtsvg
, debugSupport ? false
, guiSupport ? true, dbus ? null # GUI (disable to run headless)
, webuiSupport ? true # WebUI
, trackerSearch ? true, python3 ? null
}:
{ lib
, stdenv
, fetchFromGitHub

, boost
, cmake
, Cocoa
, libtorrent-rasterbar
, ninja
, qtbase
, qtsvg
, qttools
, wrapQtAppsHook

assert guiSupport -> (dbus != null);
assert trackerSearch -> (python3 != null);
, guiSupport ? true
, dbus
, qtwayland

mkDerivation rec {
  pname = "qbittorrent" + lib.optionalString (!guiSupport) "-nox";
  version = "4.5.5";
, trackerSearch ? true
, python3

, webuiSupport ? true
}:

let
  qtVersion = lib.versions.major qtbase.version;
in
stdenv.mkDerivation rec {
  pname = "qbittorrent"
    + lib.optionalString (guiSupport && qtVersion == "5") "-qt5"
    + lib.optionalString (!guiSupport) "-nox";
  version = "4.6.0";

  src = fetchFromGitHub {
    owner = "qbittorrent";
    repo = "qBittorrent";
    rev = "release-${version}";
    hash = "sha256-rWv+KGw+3385GOKK4MvoSP0CepotUZELiDVFpyDf+9k=";
    hash = "sha256-o9zMGjVCXLqdRdXzRs1kFPDMFJXQWBEtWwIfeIyFxJw=";
  };

  enableParallelBuilding = true;

  # NOTE: 2018-05-31: CMake is working but it is not officially supported
  nativeBuildInputs = [ pkg-config ];

  buildInputs = [ boost libtorrent-rasterbar qtbase qttools qtsvg ]
    ++ lib.optional guiSupport dbus # D(esktop)-Bus depends on GUI support
    ++ lib.optional trackerSearch python3;
  nativeBuildInputs = [
    cmake
    ninja
    wrapQtAppsHook
  ];

  # Otherwise qm_gen.pri assumes lrelease-qt5, which does not exist.
  QMAKE_LRELEASE = "lrelease";
  buildInputs = [
    boost
    libtorrent-rasterbar
    qtbase
    qtsvg
    qttools
  ] ++ lib.optionals stdenv.isDarwin [
    Cocoa
  ] ++ lib.optionals guiSupport [
    dbus
  ] ++ lib.optionals (guiSupport && stdenv.isLinux) [
    qtwayland
  ] ++ lib.optionals trackerSearch [
    python3
  ];

  configureFlags = [
    "--with-boost-libdir=${boost.out}/lib"
    "--with-boost=${boost.dev}" ]
    ++ lib.optionals (!guiSupport) [ "--disable-gui" "--enable-systemd" ] # Also place qbittorrent-nox systemd service files
    ++ lib.optional (!webuiSupport) "--disable-webui"
    ++ lib.optional debugSupport "--enable-debug";
  cmakeFlags = lib.optionals (qtVersion == "6") [
    "-DQT6=ON"
  ] ++ lib.optionals (!guiSupport) [
    "-DGUI=OFF"
    "-DSYSTEMD=ON"
    "-DSYSTEMD_SERVICES_INSTALL_DIR=${placeholder "out"}/lib/systemd/system"
  ] ++ lib.optionals (!webuiSupport) [
    "-DWEBUI=OFF"
  ];

  qtWrapperArgs = lib.optional trackerSearch "--prefix PATH : ${lib.makeBinPath [ python3 ]}";
  qtWrapperArgs = lib.optionals trackerSearch [
    "--prefix PATH : ${lib.makeBinPath [ python3 ]}"
  ];

  postInstall = lib.optionalString stdenv.isDarwin ''
    APP_NAME=qbittorrent${lib.optionalString (!guiSupport) "-nox"}
    mkdir -p $out/{Applications,bin}
    cp -R src/${pname}.app $out/Applications
    makeWrapper $out/{Applications/${pname}.app/Contents/MacOS,bin}/${pname}
    cp -R $APP_NAME.app $out/Applications
    makeWrapper $out/{Applications/$APP_NAME.app/Contents/MacOS,bin}/$APP_NAME
  '';

  meta = with lib; {
    description = "Featureful free software BitTorrent client";
    homepage    = "https://www.qbittorrent.org/";
    homepage = "https://www.qbittorrent.org";
    changelog = "https://github.com/qbittorrent/qBittorrent/blob/release-${version}/Changelog";
    license = licenses.gpl2Plus;
    platforms = platforms.unix;
    maintainers = with maintainers; [ Anton-Latukha kashw2 ];
    maintainers = with maintainers; [ Anton-Latukha kashw2 paveloom ];
  };
}
+6 −3
Original line number Diff line number Diff line
@@ -34878,9 +34878,12 @@ with pkgs;
  pyrosimple = callPackage ../applications/networking/p2p/pyrosimple { };
  qbittorrent = libsForQt5.callPackage ../applications/networking/p2p/qbittorrent { };
  qbittorrent-nox = qbittorrent.override {
    guiSupport = false;
  qbittorrent = qt6Packages.callPackage ../applications/networking/p2p/qbittorrent {
    inherit (darwin.apple_sdk.frameworks) Cocoa;
  };
  qbittorrent-nox = qbittorrent.override { guiSupport = false; };
  qbittorrent-qt5 = libsForQt5.callPackage ../applications/networking/p2p/qbittorrent {
    inherit (darwin.apple_sdk.frameworks) Cocoa;
  };
  qcad = libsForQt5.callPackage ../applications/misc/qcad { };