36 , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
40 , apparmorRulesFromClosure
44 inherit (lib) cmakeBool optionals;
46 apparmorRules = apparmorRulesFromClosure { name = "transmission-daemon"; } ([
57 ++ optionals enableSystemd [ systemd ]
58 ++ optionals stdenv.hostPlatform.isLinux [ inotify-tools ]);
61 stdenv.mkDerivation (finalAttrs: {
62 pname = "transmission";
65 src = fetchFromGitHub {
66 owner = "transmission";
67 repo = "transmission";
68 rev = finalAttrs.version;
69 hash = "sha256-KBXvBFgrJ3njIoXrxHbHHLsiocwfd7Eba/GNI8uZA38=";
70 fetchSubmodules = true;
75 url = "https://github.com/transmission/transmission/commit/febfe49ca3ecab1a7142ecb34012c1f0b2bcdee8.patch?full_index=1";
76 hash = "sha256-Ge0+AXf/ilfMieGBAdvvImY7JOb0gGIdeKprC37AROs=";
78 # The submodule that we don't use (we use our miniupnp)
79 "third-party/miniupnp"
80 # Hunk fails for this one, but we don't care because we don't rely upon
81 # xcode definitions even for the Darwin build.
82 "Transmission.xcodeproj/project.pbxproj"
87 outputs = [ "out" "apparmor" ];
90 (cmakeBool "ENABLE_CLI" enableCli)
91 (cmakeBool "ENABLE_DAEMON" enableDaemon)
92 (cmakeBool "ENABLE_GTK" enableGTK3)
93 (cmakeBool "ENABLE_MAC" false) # requires xcodebuild
94 (cmakeBool "ENABLE_QT" (enableQt5 || enableQt6))
95 (cmakeBool "INSTALL_LIB" installLib)
96 ] ++ optionals stdenv.hostPlatform.isDarwin [
97 # Transmission sets this to 10.13 if not explicitly specified, see https://github.com/transmission/transmission/blob/0be7091eb12f4eb55f6690f313ef70a66795ee72/CMakeLists.txt#L7-L16.
98 "-DCMAKE_OSX_DEPLOYMENT_TARGET=${stdenv.hostPlatform.darwinMinVersion}"
102 # Clean third-party libraries to ensure system ones are used.
103 # Excluding gtest since it is hardcoded to vendored version. The rest of the listed libraries are not packaged.
106 if [[ ! $f =~ googletest|wildmat|fast_float|wide-integer|jsonsl ]]; then
112 cmake/FindFmt.cmake \
113 cmake/FindUtfCpp.cmake
114 # Upstream uses different config file name.
115 substituteInPlace CMakeLists.txt --replace 'find_package(UtfCpp)' 'find_package(utf8cpp)'
118 nativeBuildInputs = [
123 ++ optionals enableGTK3 [ wrapGAppsHook3 ]
124 ++ optionals enableQt5 [ qt5.wrapQtAppsHook ]
125 ++ optionals enableQt6 [ qt6Packages.wrapQtAppsHook ]
144 ++ optionals enableQt5 (with qt5; [ qttools qtbase ])
145 ++ optionals enableQt6 (with qt6Packages; [ qttools qtbase qtsvg ])
146 ++ optionals enableGTK3 [ gtkmm3 xorg.libpthreadstubs ]
147 ++ optionals enableSystemd [ systemd ]
148 ++ optionals stdenv.hostPlatform.isLinux [ inotify-tools ]
149 ++ optionals stdenv.hostPlatform.isDarwin [ libiconv Foundation ];
153 cat >$apparmor/bin.transmission-daemon <<EOF
154 include <tunables/global>
155 $out/bin/transmission-daemon {
156 include <abstractions/base>
157 include <abstractions/nameservice>
158 include <abstractions/ssl_certs>
159 include "${apparmorRules}"
160 r @{PROC}/sys/kernel/random/uuid,
161 r @{PROC}/sys/vm/overcommit_memory,
162 r @{PROC}/@{pid}/environ,
163 r @{PROC}/@{pid}/mounts,
164 rwk /tmp/tr_session_id_*,
166 r $out/share/transmission/public_html/**,
168 include <local/bin.transmission-daemon>
171 install -Dm0444 -t $out/share/icons ../qt/icons/transmission.svg
175 apparmor = nixosTests.transmission_4; # starts the service with apparmor enabled
176 smoke-test = nixosTests.bittorrent;
180 description = "Fast, easy and free BitTorrent client";
181 mainProgram = if (enableQt5 || enableQt6) then "transmission-qt" else if enableGTK3 then "transmission-gtk" else "transmission-cli";
183 Transmission is a BitTorrent client which features a simple interface
184 on top of a cross-platform back-end.
186 * Uses fewer resources than other clients
187 * Native Mac, GTK and Qt GUI clients
188 * Daemon ideal for servers, embedded systems, and headless use
189 * All these can be remote controlled by Web and Terminal clients
190 * Bluetack (PeerGuardian) blocklists with automatic updates
191 * Full encryption, DHT, and PEX support
193 homepage = "https://www.transmissionbt.com/";
194 license = with licenses; [ gpl2Plus mit ];
195 maintainers = with maintainers; [ astsmtl ];
196 platforms = platforms.unix;