37 enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
41 apparmorRulesFromClosure,
45 inherit (lib) cmakeBool optionals;
47 apparmorRules = apparmorRulesFromClosure { name = "transmission-daemon"; } (
59 ++ optionals enableSystemd [ systemd ]
60 ++ optionals stdenv.hostPlatform.isLinux [ inotify-tools ]
64 stdenv.mkDerivation (finalAttrs: {
65 pname = "transmission";
68 src = fetchFromGitHub {
69 owner = "transmission";
70 repo = "transmission";
71 rev = finalAttrs.version;
72 hash = "sha256-KBXvBFgrJ3njIoXrxHbHHLsiocwfd7Eba/GNI8uZA38=";
73 fetchSubmodules = true;
78 url = "https://github.com/transmission/transmission/commit/febfe49ca3ecab1a7142ecb34012c1f0b2bcdee8.patch?full_index=1";
79 hash = "sha256-Ge0+AXf/ilfMieGBAdvvImY7JOb0gGIdeKprC37AROs=";
81 # The submodule that we don't use (we use our miniupnp)
82 "third-party/miniupnp"
83 # Hunk fails for this one, but we don't care because we don't rely upon
84 # xcode definitions even for the Darwin build.
85 "Transmission.xcodeproj/project.pbxproj"
97 (cmakeBool "ENABLE_CLI" enableCli)
98 (cmakeBool "ENABLE_DAEMON" enableDaemon)
99 (cmakeBool "ENABLE_GTK" enableGTK3)
100 (cmakeBool "ENABLE_MAC" false) # requires xcodebuild
101 (cmakeBool "ENABLE_QT" (enableQt5 || enableQt6))
102 (cmakeBool "INSTALL_LIB" installLib)
104 ++ optionals stdenv.hostPlatform.isDarwin [
105 # Transmission sets this to 10.13 if not explicitly specified, see https://github.com/transmission/transmission/blob/0be7091eb12f4eb55f6690f313ef70a66795ee72/CMakeLists.txt#L7-L16.
106 "-DCMAKE_OSX_DEPLOYMENT_TARGET=${stdenv.hostPlatform.darwinMinVersion}"
110 # Clean third-party libraries to ensure system ones are used.
111 # Excluding gtest since it is hardcoded to vendored version. The rest of the listed libraries are not packaged.
114 if [[ ! $f =~ googletest|wildmat|fast_float|wide-integer|jsonsl ]]; then
120 cmake/FindFmt.cmake \
121 cmake/FindUtfCpp.cmake
122 # Upstream uses different config file name.
123 substituteInPlace CMakeLists.txt --replace 'find_package(UtfCpp)' 'find_package(utf8cpp)'
125 # Use gettext even on Darwin
126 substituteInPlace libtransmission/utils.h \
127 --replace-fail '#if defined(HAVE_GETTEXT) && !defined(__APPLE__)' '#if defined(HAVE_GETTEXT)'
136 ++ optionals enableGTK3 [ wrapGAppsHook3 ]
137 ++ optionals enableQt5 [ qt5.wrapQtAppsHook ]
138 ++ optionals enableQt6 [ qt6Packages.wrapQtAppsHook ];
157 ++ optionals enableQt5 (
164 ++ optionals enableQt6 (
172 ++ optionals enableGTK3 [
176 ++ optionals enableSystemd [ systemd ]
177 ++ optionals stdenv.hostPlatform.isLinux [ inotify-tools ];
181 cat >$apparmor/bin.transmission-daemon <<EOF
182 include <tunables/global>
183 $out/bin/transmission-daemon {
184 include <abstractions/base>
185 include <abstractions/nameservice>
186 include <abstractions/ssl_certs>
187 include "${apparmorRules}"
188 r @{PROC}/sys/kernel/random/uuid,
189 r @{PROC}/sys/vm/overcommit_memory,
190 r @{PROC}/@{pid}/environ,
191 r @{PROC}/@{pid}/mounts,
192 rwk /tmp/tr_session_id_*,
194 r $out/share/transmission/public_html/**,
196 include <local/bin.transmission-daemon>
199 install -Dm0444 -t $out/share/icons ../qt/icons/transmission.svg
203 apparmor = nixosTests.transmission_4; # starts the service with apparmor enabled
204 smoke-test = nixosTests.bittorrent;
208 description = "Fast, easy and free BitTorrent client";
210 if (enableQt5 || enableQt6) then
212 else if enableGTK3 then
217 Transmission is a BitTorrent client which features a simple interface
218 on top of a cross-platform back-end.
220 * Uses fewer resources than other clients
221 * Native Mac, GTK and Qt GUI clients
222 * Daemon ideal for servers, embedded systems, and headless use
223 * All these can be remote controlled by Web and Terminal clients
224 * Bluetack (PeerGuardian) blocklists with automatic updates
225 * Full encryption, DHT, and PEX support
227 homepage = "https://www.transmissionbt.com/";
228 license = with licenses; [
232 maintainers = with maintainers; [ astsmtl ];
233 platforms = platforms.unix;