summary refs log tree commit diff
path: root/pkgs/applications/misc/syncthingtray/default.nix
blob: 4f1a5fdef6b3e710ecfcc45f934418c3738c2b38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{ mkDerivation
, lib
, stdenv
, fetchFromGitHub
, substituteAll
, qtbase
, qtwebengine
, qtdeclarative
, extra-cmake-modules
, cpp-utilities
, qtutilities
, qtforkawesome
, boost
, wrapQtAppsHook
, cmake
, kio
, plasma-framework
, qttools
, iconv
, cppunit
, syncthing
, webviewSupport ? true
, jsSupport ? true
, kioPluginSupport ? stdenv.isLinux
, plasmoidSupport  ? stdenv.isLinux
, systemdSupport ? stdenv.isLinux
/* It is possible to set via this option an absolute exec path that will be
written to the `~/.config/autostart/syncthingtray.desktop` file generated
during runtime. Alternatively, one can edit the desktop file themselves after
it is generated See:
https://github.com/NixOS/nixpkgs/issues/199596#issuecomment-1310136382 */
, autostartExecPath ? "syncthingtray"
}:

stdenv.mkDerivation (finalAttrs: {
  version = "1.4.8";
  pname = "syncthingtray";

  src = fetchFromGitHub {
    owner = "Martchus";
    repo = "syncthingtray";
    rev = "v${finalAttrs.version}";
    sha256 = "sha256-Fy3cy6c36Qsi8F7cC/MI8g6tdfkn8fDBncL+ZOoiGcs=";
  };

  buildInputs = [
    qtbase
    cpp-utilities
    qtutilities
    boost
    qtforkawesome
  ] ++ lib.optionals stdenv.isDarwin [ iconv ]
    ++ lib.optionals webviewSupport [ qtwebengine ]
    ++ lib.optionals jsSupport [ qtdeclarative ]
    ++ lib.optionals kioPluginSupport [ kio ]
    ++ lib.optionals plasmoidSupport [ plasma-framework ]
  ;

  nativeBuildInputs = [
    wrapQtAppsHook
    cmake
    qttools
    # Although these are test dependencies, we add them anyway so that we test
    # whether the test units compile. On Darwin we don't run the tests but we
    # still build them.
    cppunit
    syncthing
  ]
    ++ lib.optionals plasmoidSupport [ extra-cmake-modules ]
  ;

  # syncthing server seems to hang on darwin, causing tests to fail.
  doCheck = !stdenv.isDarwin;
  preCheck = ''
    export QT_QPA_PLATFORM=offscreen
    export QT_PLUGIN_PATH="${qtbase.bin}/${qtbase.qtPluginPrefix}"
  '';
  # don't test --help  on Darwin because output is .app
  doInstallCheck = !stdenv.isDarwin;
  installCheckPhase = ''
    $out/bin/syncthingtray --help | grep ${finalAttrs.version}
  '';

  cmakeFlags = [
    "-DBUILD_TESTING=ON"
    # See https://github.com/Martchus/syncthingtray/issues/208
    "-DEXCLUDE_TESTS_FROM_ALL=OFF"
    "-DAUTOSTART_EXEC_PATH=${autostartExecPath}"
    # See https://github.com/Martchus/syncthingtray/issues/42
    "-DQT_PLUGIN_DIR:STRING=${placeholder "out"}/${qtbase.qtPluginPrefix}"
    "-DBUILD_SHARED_LIBS=ON"
  ] ++ lib.optionals (!plasmoidSupport) ["-DNO_PLASMOID=ON"]
    ++ lib.optionals (!kioPluginSupport) ["-DNO_FILE_ITEM_ACTION_PLUGIN=ON"]
    ++ lib.optionals systemdSupport ["-DSYSTEMD_SUPPORT=ON"]
    ++ lib.optionals (!webviewSupport) ["-DWEBVIEW_PROVIDER:STRING=none"]
  ;

  meta = with lib; {
    homepage = "https://github.com/Martchus/syncthingtray";
    description = "Tray application and Dolphin/Plasma integration for Syncthing";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ doronbehar ];
    platforms = platforms.linux ++ platforms.darwin;
  };
})