transmission_4-qt: support for qt6

This commit is contained in:
Peter Hoeg 2024-03-04 11:39:02 +01:00
parent c3acc4173e
commit f0a2f90384
2 changed files with 51 additions and 35 deletions

View file

@ -27,8 +27,10 @@
, gtkmm3 , gtkmm3
, xorg , xorg
, wrapGAppsHook , wrapGAppsHook
, enableQt ? false , enableQt5 ? false
, enableQt6 ? false
, qt5 , qt5
, qt6Packages
, nixosTests , nixosTests
, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, enableDaemon ? true , enableDaemon ? true
@ -37,6 +39,24 @@
, apparmorRulesFromClosure , apparmorRulesFromClosure
}: }:
let
inherit (lib) cmakeBool optionals;
apparmorRules = apparmorRulesFromClosure { name = "transmission-daemon"; } ([
curl
libdeflate
libevent
libnatpmp
libpsl
miniupnpc
openssl
pcre
zlib
]
++ optionals enableSystemd [ systemd ]
++ optionals stdenv.isLinux [ inotify-tools ]);
in
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "transmission"; pname = "transmission";
version = "4.0.5"; version = "4.0.5";
@ -51,21 +71,17 @@ stdenv.mkDerivation (finalAttrs: {
outputs = [ "out" "apparmor" ]; outputs = [ "out" "apparmor" ];
cmakeFlags = cmakeFlags = [
let (cmakeBool "ENABLE_CLI" enableCli)
mkFlag = opt: if opt then "ON" else "OFF"; (cmakeBool "ENABLE_DAEMON" enableDaemon)
in (cmakeBool "ENABLE_GTK" enableGTK3)
[ (cmakeBool "ENABLE_MAC" false) # requires xcodebuild
"-DENABLE_MAC=OFF" # requires xcodebuild (cmakeBool "ENABLE_QT" (enableQt5 || enableQt6))
"-DENABLE_GTK=${mkFlag enableGTK3}" (cmakeBool "INSTALL_LIB" installLib)
"-DENABLE_QT=${mkFlag enableQt}" ] ++ optionals stdenv.isDarwin [
"-DENABLE_DAEMON=${mkFlag enableDaemon}" # Transmission sets this to 10.13 if not explicitly specified, see https://github.com/transmission/transmission/blob/0be7091eb12f4eb55f6690f313ef70a66795ee72/CMakeLists.txt#L7-L16.
"-DENABLE_CLI=${mkFlag enableCli}" "-DCMAKE_OSX_DEPLOYMENT_TARGET=${stdenv.hostPlatform.darwinMinVersion}"
"-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 = '' postPatch = ''
# Clean third-party libraries to ensure system ones are used. # Clean third-party libraries to ensure system ones are used.
@ -89,8 +105,9 @@ stdenv.mkDerivation (finalAttrs: {
cmake cmake
python3 python3
] ]
++ lib.optionals enableGTK3 [ wrapGAppsHook ] ++ optionals enableGTK3 [ wrapGAppsHook ]
++ lib.optionals enableQt [ qt5.wrapQtAppsHook ] ++ optionals enableQt5 [ qt5.wrapQtAppsHook ]
++ optionals enableQt6 [ qt6Packages.wrapQtAppsHook ]
; ;
buildInputs = [ buildInputs = [
@ -109,11 +126,12 @@ stdenv.mkDerivation (finalAttrs: {
utf8cpp utf8cpp
zlib zlib
] ]
++ lib.optionals enableQt [ qt5.qttools qt5.qtbase ] ++ optionals enableQt5 (with qt5; [ qttools qtbase ])
++ lib.optionals enableGTK3 [ gtkmm3 xorg.libpthreadstubs ] ++ optionals enableQt6 (with qt6Packages; [ qttools qtbase qtsvg ])
++ lib.optionals enableSystemd [ systemd ] ++ optionals enableGTK3 [ gtkmm3 xorg.libpthreadstubs ]
++ lib.optionals stdenv.isLinux [ inotify-tools ] ++ optionals enableSystemd [ systemd ]
++ lib.optionals stdenv.isDarwin [ libiconv Foundation ]; ++ optionals stdenv.isLinux [ inotify-tools ]
++ optionals stdenv.isDarwin [ libiconv Foundation ];
postInstall = '' postInstall = ''
mkdir $apparmor mkdir $apparmor
@ -123,11 +141,7 @@ stdenv.mkDerivation (finalAttrs: {
include <abstractions/base> include <abstractions/base>
include <abstractions/nameservice> include <abstractions/nameservice>
include <abstractions/ssl_certs> include <abstractions/ssl_certs>
include "${apparmorRulesFromClosure { name = "transmission-daemon"; } ([ include "${apparmorRules}"
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/kernel/random/uuid,
r @{PROC}/sys/vm/overcommit_memory, r @{PROC}/sys/vm/overcommit_memory,
r @{PROC}/@{pid}/environ, r @{PROC}/@{pid}/environ,
@ -147,9 +161,9 @@ stdenv.mkDerivation (finalAttrs: {
smoke-test = nixosTests.bittorrent; smoke-test = nixosTests.bittorrent;
}; };
meta = { meta = with lib; {
description = "A fast, easy and free BitTorrent client"; description = "A fast, easy and free BitTorrent client";
mainProgram = if enableQt then "transmission-qt" else if enableGTK3 then "transmission-gtk" else "transmission-cli"; mainProgram = if (enableQt5 || enableQt6) then "transmission-qt" else if enableGTK3 then "transmission-gtk" else "transmission-cli";
longDescription = '' longDescription = ''
Transmission is a BitTorrent client which features a simple interface Transmission is a BitTorrent client which features a simple interface
on top of a cross-platform back-end. on top of a cross-platform back-end.
@ -161,9 +175,9 @@ stdenv.mkDerivation (finalAttrs: {
* Bluetack (PeerGuardian) blocklists with automatic updates * Bluetack (PeerGuardian) blocklists with automatic updates
* Full encryption, DHT, and PEX support * Full encryption, DHT, and PEX support
''; '';
homepage = "http://www.transmissionbt.com/"; homepage = "https://www.transmissionbt.com/";
license = with lib.licenses; [ gpl2Plus mit ]; license = with licenses; [ gpl2Plus mit ];
maintainers = with lib.maintainers; [ astsmtl ]; maintainers = with maintainers; [ astsmtl ];
platforms = lib.platforms.unix; platforms = platforms.unix;
}; };
}) })

View file

@ -35562,7 +35562,9 @@ with pkgs;
enableCli = false; enableCli = false;
}; };
transmission_4-gtk = transmission_4.override { enableGTK3 = true; }; transmission_4-gtk = transmission_4.override { enableGTK3 = true; };
transmission_4-qt = transmission_4.override { enableQt = true; }; transmission_4-qt5 = transmission_4.override { enableQt5 = true; };
transmission_4-qt6 = transmission_4.override { enableQt6 = true; };
transmission_4-qt = transmission_4-qt5;
transmission-remote-gtk = callPackage ../applications/networking/p2p/transmission-remote-gtk { }; transmission-remote-gtk = callPackage ../applications/networking/p2p/transmission-remote-gtk { };