1{
2 stdenv,
3 lib,
4 fetchFromGitLab,
5 gitUpdater,
6 testers,
7 # https://gitlab.com/ubports/development/core/biometryd/-/issues/8
8 boost186,
9 cmake,
10 cmake-extras,
11 dbus,
12 dbus-cpp,
13 gtest,
14 libapparmor,
15 libelf,
16 pkg-config,
17 process-cpp,
18 properties-cpp,
19 qtbase,
20 qtdeclarative,
21 sqlite,
22 validatePkgConfig,
23}:
24
25stdenv.mkDerivation (finalAttrs: {
26 pname = "biometryd";
27 version = "0.3.1";
28
29 src = fetchFromGitLab {
30 owner = "ubports";
31 repo = "development/core/biometryd";
32 rev = finalAttrs.version;
33 hash = "sha256-derU7pKdNf6pwhskaW7gCLcU9ixBG3U0EI/qtANmmTs=";
34 };
35
36 outputs = [
37 "out"
38 "dev"
39 ];
40
41 postPatch = ''
42 # GTest needs C++17
43 # Remove when https://gitlab.com/ubports/development/core/biometryd/-/merge_requests/39 merged & in release
44 substituteInPlace CMakeLists.txt \
45 --replace-fail 'std=c++14' 'std=c++17'
46
47 # Substitute systemd's prefix in pkg-config call
48 substituteInPlace data/CMakeLists.txt \
49 --replace-fail 'pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir)' 'pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir DEFINE_VARIABLES prefix=''${CMAKE_INSTALL_PREFIX})'
50
51 substituteInPlace src/biometry/qml/Biometryd/CMakeLists.txt \
52 --replace-fail "\''${CMAKE_INSTALL_LIBDIR}/qt5/qml" "\''${CMAKE_INSTALL_PREFIX}/${qtbase.qtQmlPrefix}"
53
54 # For our automatic pkg-config output patcher to work, prefix must be used here
55 substituteInPlace data/biometryd.pc.in \
56 --replace-fail 'libdir=''${exec_prefix}' 'libdir=''${prefix}' \
57 --replace-fail 'includedir=''${exec_prefix}' 'includedir=''${prefix}' \
58 ''
59 + lib.optionalString (!finalAttrs.finalPackage.doCheck) ''
60 sed -i -e '/add_subdirectory(tests)/d' CMakeLists.txt
61 '';
62
63 strictDeps = true;
64
65 nativeBuildInputs = [
66 cmake
67 pkg-config
68 qtdeclarative # qmlplugindump
69 validatePkgConfig
70 ];
71
72 buildInputs = [
73 boost186
74 cmake-extras
75 dbus
76 dbus-cpp
77 libapparmor
78 libelf
79 process-cpp
80 properties-cpp
81 qtbase
82 qtdeclarative
83 sqlite
84 ];
85
86 checkInputs = [
87 gtest
88 ];
89
90 dontWrapQtApps = true;
91
92 cmakeFlags = [
93 # maybe-uninitialized warnings
94 (lib.cmakeBool "ENABLE_WERROR" false)
95 (lib.cmakeBool "WITH_HYBRIS" false)
96 ];
97
98 preBuild = ''
99 # Generating plugins.qmltypes (also used in checkPhase?)
100 export QT_PLUGIN_PATH=${lib.getBin qtbase}/${qtbase.qtPluginPrefix}
101 '';
102
103 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
104
105 passthru = {
106 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
107 updateScript = gitUpdater { };
108 };
109
110 meta = with lib; {
111 description = "Mediates/multiplexes access to biometric devices";
112 longDescription = ''
113 biometryd mediates and multiplexes access to biometric devices present
114 on the system, enabling applications and system components to leverage
115 them for identification and verification of users.
116 '';
117 homepage = "https://gitlab.com/ubports/development/core/biometryd";
118 changelog = "https://gitlab.com/ubports/development/core/biometryd/-/${finalAttrs.version}/ChangeLog";
119 license = licenses.lgpl3Only;
120 teams = [ teams.lomiri ];
121 mainProgram = "biometryd";
122 platforms = platforms.linux;
123 pkgConfigModules = [
124 "biometryd"
125 ];
126 };
127})