1{
2 stdenv,
3 lib,
4 fetchFromGitLab,
5 fetchpatch,
6 gitUpdater,
7 testers,
8 # dbus-cpp not compatible with Boost 1.87
9 # https://gitlab.com/ubports/development/core/lib-cpp/dbus-cpp/-/issues/8
10 boost186,
11 cmake,
12 cmake-extras,
13 dbus,
14 dbus-cpp,
15 doxygen,
16 gettext,
17 glog,
18 graphviz,
19 gtest,
20 libapparmor,
21 newt,
22 pkg-config,
23 process-cpp,
24 properties-cpp,
25 qtbase,
26 qtdeclarative,
27 validatePkgConfig,
28}:
29
30stdenv.mkDerivation (finalAttrs: {
31 pname = "trust-store";
32 version = "2.0.2";
33
34 src = fetchFromGitLab {
35 owner = "ubports";
36 repo = "development/core/trust-store";
37 rev = finalAttrs.version;
38 hash = "sha256-tVwqBu4py8kdydyKECZfLvcLijpZSQszeo8ytTDagy0=";
39 };
40
41 outputs = [
42 "out"
43 "dev"
44 "doc"
45 "bin"
46 ];
47
48 patches = [
49 # Remove when version > 2.0.2
50 (fetchpatch {
51 name = "0001-trust-store-Fix-boost-184-compat.patch";
52 url = "https://gitlab.com/ubports/development/core/trust-store/-/commit/569f6b35d8bcdb2ae5ff84549cd92cfc0899675b.patch";
53 hash = "sha256-3lrdVIzscXGiLKwftC5oECICVv3sBoS4UedfRHx7uOs=";
54 })
55
56 # Fix compatibility with glog 0.7.x
57 # Remove when https://gitlab.com/ubports/development/core/trust-store/-/merge_requests/18 merged & in release
58 ./1001-treewide-Switch-to-glog-CMake-module.patch
59 ];
60
61 postPatch = ''
62 # pkg-config patching hook expects prefix variable
63 substituteInPlace data/trust-store.pc.in \
64 --replace-fail 'libdir=''${exec_prefix}' 'libdir=''${prefix}' \
65 --replace-fail 'includedir=''${exec_prefix}' 'includedir=''${prefix}'
66
67 substituteInPlace src/core/trust/terminal_agent.h \
68 --replace-fail '/bin/whiptail' '${lib.getExe' newt "whiptail"}'
69 ''
70 + lib.optionalString (!finalAttrs.finalPackage.doCheck) ''
71 substituteInPlace CMakeLists.txt \
72 --replace-fail 'add_subdirectory(tests)' ""
73 '';
74
75 strictDeps = true;
76
77 nativeBuildInputs = [
78 cmake
79 doxygen
80 gettext
81 graphviz
82 pkg-config
83 validatePkgConfig
84 ];
85
86 buildInputs = [
87 boost186
88 cmake-extras
89 dbus-cpp
90 glog
91 libapparmor
92 newt
93 process-cpp
94 properties-cpp
95 qtbase
96 qtdeclarative
97 ];
98
99 nativeCheckInputs = [
100 dbus
101 ];
102
103 checkInputs = [
104 gtest
105 ];
106
107 dontWrapQtApps = true;
108
109 cmakeFlags = [
110 # Requires mirclient API, unavailable in Mir 2.x
111 # https://gitlab.com/ubports/development/core/trust-store/-/issues/2
112 (lib.cmakeBool "TRUST_STORE_MIR_AGENT_ENABLED" false)
113 (lib.cmakeBool "TRUST_STORE_ENABLE_DOC_GENERATION" true)
114 # error: moving a temporary object prevents copy elision
115 (lib.cmakeBool "ENABLE_WERROR" false)
116 ];
117
118 # Not working
119 # - remote_agent_test cases using unix domain socket fail to do *something*, with std::system_error "Invalid argument" + follow-up "No such file or directory".
120 # potentially something broken/missing on our end
121 # - dbus_test hangs indefinitely waiting for a std::future, not provicient enough to debug this.
122 # same hang on upstream CI
123 doCheck = false;
124
125 preCheck = ''
126 export XDG_DATA_HOME=$TMPDIR
127 '';
128
129 # Starts & talks to DBus
130 enableParallelChecking = false;
131
132 passthru = {
133 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
134 updateScript = gitUpdater { };
135 };
136
137 meta = with lib; {
138 description = "Common implementation of a trust store to be used by trusted helpers";
139 homepage = "https://gitlab.com/ubports/development/core/trust-store";
140 license = licenses.lgpl3Only;
141 teams = [ teams.lomiri ];
142 platforms = platforms.linux;
143 pkgConfigModules = [
144 "trust-store"
145 ];
146 };
147})