about summary refs log tree commit diff
path: root/pkgs/applications
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications')
-rw-r--r--pkgs/applications/networking/p2p/libutp/3.4.nix30
-rw-r--r--pkgs/applications/networking/p2p/transmission/4.nix164
2 files changed, 194 insertions, 0 deletions
diff --git a/pkgs/applications/networking/p2p/libutp/3.4.nix b/pkgs/applications/networking/p2p/libutp/3.4.nix
new file mode 100644
index 0000000000000..4ea4ebbb2dc4e
--- /dev/null
+++ b/pkgs/applications/networking/p2p/libutp/3.4.nix
@@ -0,0 +1,30 @@
+{ stdenv, lib, fetchFromGitHub, cmake, unstableGitUpdater }:
+
+stdenv.mkDerivation rec {
+  pname = "libutp";
+  version = "unstable-2023-03-05";
+
+  src = fetchFromGitHub {
+    # Use transmission fork from post-3.4-transmission branch
+    owner = "transmission";
+    repo = pname;
+    rev = "9cb9f9c4f0073d78b08d6542cebaea6564ecadfe";
+    hash = "sha256-dpbX1h/gpuVIAXC4hwwuRwQDJ0pwVVEsgemOVN0Dv9Q=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  passthru = {
+    updateScript = unstableGitUpdater {
+      branch = "post-3.4-transmission";
+    };
+  };
+
+  meta = with lib; {
+    description = "uTorrent Transport Protocol library";
+    homepage = "https://github.com/transmission/libutp";
+    license = licenses.mit;
+    maintainers = with maintainers; [ emilytrau ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/applications/networking/p2p/transmission/4.nix b/pkgs/applications/networking/p2p/transmission/4.nix
new file mode 100644
index 0000000000000..d388f07e01501
--- /dev/null
+++ b/pkgs/applications/networking/p2p/transmission/4.nix
@@ -0,0 +1,164 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, cmake
+, pkg-config
+, python3
+, openssl
+, curl
+, libevent
+, inotify-tools
+, systemd
+, zlib
+, pcre
+, libb64
+, libutp
+, libdeflate
+, utf8cpp
+, fmt
+, libpsl
+, miniupnpc
+, dht
+, libnatpmp
+, libiconv
+, darwin
+  # Build options
+, enableGTK3 ? false
+, gtkmm3
+, xorg
+, wrapGAppsHook
+, enableQt ? false
+, qt5
+, nixosTests
+, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
+, enableDaemon ? true
+, enableCli ? true
+, installLib ? false
+, apparmorRulesFromClosure
+}:
+
+stdenv.mkDerivation rec {
+  pname = "transmission";
+  version = "4.0.3";
+
+  src = fetchFromGitHub {
+    owner = "transmission";
+    repo = "transmission";
+    rev = version;
+    hash = "sha256-P7omd49xLmReo9Zrg0liO1msUVzCa5CxH7PGmH4oPzg=";
+    fetchSubmodules = true;
+  };
+
+  outputs = [ "out" "apparmor" ];
+
+  cmakeFlags =
+    let
+      mkFlag = opt: if opt then "ON" else "OFF";
+    in
+    [
+      "-DENABLE_MAC=OFF" # requires xcodebuild
+      "-DENABLE_GTK=${mkFlag enableGTK3}"
+      "-DENABLE_QT=${mkFlag enableQt}"
+      "-DENABLE_DAEMON=${mkFlag enableDaemon}"
+      "-DENABLE_CLI=${mkFlag enableCli}"
+      "-DINSTALL_LIB=${mkFlag installLib}"
+    ] ++ lib.optionals stdenv.isDarwin [
+      # Transmission sets this to 10.13 if not explicitly specified, see https://github.com/transmission/transmission/blob/0be7091eb12f4eb55f6690f313ef70a66795ee72/CMakeLists.txt#L7-L16.
+      "-DCMAKE_OSX_DEPLOYMENT_TARGET=${stdenv.hostPlatform.darwinMinVersion}"
+    ];
+
+  postPatch = ''
+    # Clean third-party libraries to ensure system ones are used.
+    # Excluding gtest since it is hardcoded to vendored version. The rest of the listed libraries are not packaged.
+    pushd third-party
+    for f in *; do
+        if [[ ! $f =~ googletest|wildmat|fast_float|wide-integer|jsonsl ]]; then
+            rm -r "$f"
+        fi
+    done
+    popd
+    rm \
+      cmake/FindFmt.cmake \
+      cmake/FindUtfCpp.cmake
+    # Upstream uses different config file name.
+    substituteInPlace CMakeLists.txt --replace 'find_package(UtfCpp)' 'find_package(utf8cpp)'
+  '';
+
+  nativeBuildInputs = [
+    pkg-config
+    cmake
+    python3
+  ]
+  ++ lib.optionals enableGTK3 [ wrapGAppsHook ]
+  ++ lib.optionals enableQt [ qt5.wrapQtAppsHook ]
+  ;
+
+  buildInputs = [
+    curl
+    dht
+    fmt
+    libb64
+    libdeflate
+    libevent
+    libnatpmp
+    libpsl
+    libutp
+    miniupnpc
+    openssl
+    pcre
+    utf8cpp
+    zlib
+  ]
+  ++ lib.optionals enableQt [ qt5.qttools qt5.qtbase ]
+  ++ lib.optionals enableGTK3 [ gtkmm3 xorg.libpthreadstubs ]
+  ++ lib.optionals enableSystemd [ systemd ]
+  ++ lib.optionals stdenv.isLinux [ inotify-tools ]
+  ++ lib.optionals stdenv.isDarwin [ libiconv darwin.apple_sdk.frameworks.Foundation ];
+
+  postInstall = ''
+    mkdir $apparmor
+    cat >$apparmor/bin.transmission-daemon <<EOF
+    include <tunables/global>
+    $out/bin/transmission-daemon {
+      include <abstractions/base>
+      include <abstractions/nameservice>
+      include <abstractions/ssl_certs>
+      include "${apparmorRulesFromClosure { name = "transmission-daemon"; } ([
+        curl libevent openssl pcre zlib libdeflate libpsl libnatpmp miniupnpc
+      ] ++ lib.optionals enableSystemd [ systemd ]
+        ++ lib.optionals stdenv.isLinux [ inotify-tools ]
+      )}"
+      r @{PROC}/sys/kernel/random/uuid,
+      r @{PROC}/sys/vm/overcommit_memory,
+      r @{PROC}/@{pid}/environ,
+      r @{PROC}/@{pid}/mounts,
+      rwk /tmp/tr_session_id_*,
+
+      r $out/share/transmission/web/**,
+
+      include <local/bin.transmission-daemon>
+    }
+    EOF
+  '';
+
+  meta = {
+    description = "A fast, easy and free BitTorrent client";
+    longDescription = ''
+      Transmission is a BitTorrent client which features a simple interface
+      on top of a cross-platform back-end.
+      Feature spotlight:
+        * Uses fewer resources than other clients
+        * Native Mac, GTK and Qt GUI clients
+        * Daemon ideal for servers, embedded systems, and headless use
+        * All these can be remote controlled by Web and Terminal clients
+        * Bluetack (PeerGuardian) blocklists with automatic updates
+        * Full encryption, DHT, and PEX support
+    '';
+    homepage = "http://www.transmissionbt.com/";
+    license = with lib.licenses; [ gpl2Plus mit ];
+    maintainers = with lib.maintainers; [ astsmtl ];
+    platforms = lib.platforms.unix;
+    # Needs macOS >= 10.14.6
+    broken = stdenv.isDarwin && stdenv.isx86_64;
+  };
+}