at master 124 lines 3.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 qtbase, 6 qtsvg, 7 qtwayland, 8 qtwebengine, 9 qtdeclarative, 10 extra-cmake-modules, 11 cpp-utilities, 12 qtutilities, 13 qtforkawesome, 14 boost, 15 wrapQtAppsHook, 16 cmake, 17 kio, 18 plasma-framework, 19 qttools, 20 iconv, 21 cppunit, 22 syncthing, 23 xdg-utils, 24 webviewSupport ? true, 25 jsSupport ? true, 26 kioPluginSupport ? stdenv.hostPlatform.isLinux, 27 plasmoidSupport ? stdenv.hostPlatform.isLinux, 28 systemdSupport ? stdenv.hostPlatform.isLinux, 29 /* 30 It is possible to set via this option an absolute exec path that will be 31 written to the `~/.config/autostart/syncthingtray.desktop` file generated 32 during runtime. Alternatively, one can edit the desktop file themselves after 33 it is generated See: 34 https://github.com/NixOS/nixpkgs/issues/199596#issuecomment-1310136382 35 */ 36 autostartExecPath ? "syncthingtray", 37 versionCheckHook, 38}: 39 40stdenv.mkDerivation (finalAttrs: { 41 version = "2.0.1"; 42 pname = "syncthingtray"; 43 44 src = fetchFromGitHub { 45 owner = "Martchus"; 46 repo = "syncthingtray"; 47 rev = "v${finalAttrs.version}"; 48 hash = "sha256-57Mq6zdSqPIK88E/CQkfwQe+Rf4kFTZ2o2shtPBWgRE="; 49 }; 50 51 buildInputs = [ 52 qtbase 53 qtsvg 54 cpp-utilities 55 qtutilities 56 boost 57 qtforkawesome 58 ] 59 ++ lib.optionals stdenv.hostPlatform.isDarwin [ iconv ] 60 ++ lib.optionals stdenv.hostPlatform.isLinux [ qtwayland ] 61 ++ lib.optionals webviewSupport [ qtwebengine ] 62 ++ lib.optionals jsSupport [ qtdeclarative ] 63 ++ lib.optionals kioPluginSupport [ kio ] 64 ++ lib.optionals plasmoidSupport [ plasma-framework ]; 65 66 nativeBuildInputs = [ 67 wrapQtAppsHook 68 cmake 69 qttools 70 # Although these are test dependencies, we add them anyway so that we test 71 # whether the test units compile. On Darwin we don't run the tests but we 72 # still build them. 73 cppunit 74 syncthing 75 ] 76 ++ lib.optionals plasmoidSupport [ extra-cmake-modules ]; 77 78 # syncthing server seems to hang on darwin, causing tests to fail. 79 doCheck = !stdenv.hostPlatform.isDarwin; 80 preCheck = '' 81 export QT_QPA_PLATFORM=offscreen 82 export QT_PLUGIN_PATH="${lib.getBin qtbase}/${qtbase.qtPluginPrefix}" 83 ''; 84 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' 85 # put the app bundle into the proper place /Applications instead of /bin 86 mkdir -p $out/Applications 87 mv $out/bin/syncthingtray.app $out/Applications 88 # Make binary available in PATH like on other platforms 89 ln -s $out/Applications/syncthingtray.app/Contents/MacOS/syncthingtray $out/bin/syncthingtray 90 ''; 91 nativeInstallCheckInputs = [ 92 versionCheckHook 93 ]; 94 doInstallCheck = true; 95 96 cmakeFlags = [ 97 "-DQT_PACKAGE_PREFIX=Qt${lib.versions.major qtbase.version}" 98 "-DKF_PACKAGE_PREFIX=KF${lib.versions.major qtbase.version}" 99 "-DBUILD_TESTING=ON" 100 # See https://github.com/Martchus/syncthingtray/issues/208 101 "-DEXCLUDE_TESTS_FROM_ALL=OFF" 102 "-DAUTOSTART_EXEC_PATH=${autostartExecPath}" 103 # See https://github.com/Martchus/syncthingtray/issues/42 104 "-DQT_PLUGIN_DIR:STRING=${placeholder "out"}/${qtbase.qtPluginPrefix}" 105 "-DBUILD_SHARED_LIBS=ON" 106 ] 107 ++ lib.optionals (!plasmoidSupport) [ "-DNO_PLASMOID=ON" ] 108 ++ lib.optionals (!kioPluginSupport) [ "-DNO_FILE_ITEM_ACTION_PLUGIN=ON" ] 109 ++ lib.optionals systemdSupport [ "-DSYSTEMD_SUPPORT=ON" ] 110 ++ lib.optionals (!webviewSupport) [ "-DWEBVIEW_PROVIDER:STRING=none" ]; 111 112 qtWrapperArgs = [ 113 "--prefix PATH : ${lib.makeBinPath [ xdg-utils ]}" 114 ]; 115 116 meta = with lib; { 117 homepage = "https://github.com/Martchus/syncthingtray"; 118 description = "Tray application and Dolphin/Plasma integration for Syncthing"; 119 license = licenses.gpl2Plus; 120 maintainers = with maintainers; [ doronbehar ]; 121 platforms = platforms.linux ++ platforms.darwin; 122 mainProgram = "syncthingtray"; 123 }; 124})