1{ stdenv
2, lib
3, fetchurl
4, fetchpatch
5, gettext
6, meson
7, mesonEmulatorHook
8, ninja
9, pkg-config
10, asciidoc
11, gobject-introspection
12, buildPackages
13, withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
14, vala
15, python3
16, gi-docgen
17, graphviz
18, libxml2
19, glib
20, wrapGAppsNoGuiHook
21, sqlite
22, libstemmer
23, gnome
24, icu
25, libuuid
26, libsoup
27, libsoup_3
28, json-glib
29, systemd
30, dbus
31, writeText
32}:
33
34stdenv.mkDerivation rec {
35 pname = "tracker";
36 version = "3.5.3";
37
38 outputs = [ "out" "dev" "devdoc" ];
39
40 src = fetchurl {
41 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
42 sha256 = "FGbIsIl75dngVth+EK1YkntYgDPwGvLxplaokhw6KO4=";
43 };
44
45 patches = [
46 # Backport sqlite-3.42.0 compatibility:
47 # https://gitlab.gnome.org/GNOME/tracker/-/merge_requests/600
48 (fetchpatch {
49 name = "sqlite-3.42.0.patch";
50 url = "https://gitlab.gnome.org/GNOME/tracker/-/commit/4cbbd1773a7367492fa3b3e3804839654e18a12a.patch";
51 hash = "sha256-w5D9I0P1DdyILhpjslh6ifojmlUiBoeFnxHPIr0rO3s=";
52 })
53 ];
54
55 strictDeps = true;
56
57 depsBuildBuild = [
58 pkg-config
59 ];
60
61 nativeBuildInputs = [
62 meson
63 ninja
64 pkg-config
65 asciidoc
66 gettext
67 glib
68 wrapGAppsNoGuiHook
69 gi-docgen
70 graphviz
71 (python3.pythonOnBuildForHost.withPackages (p: [ p.pygobject3 ]))
72 ] ++ lib.optionals withIntrospection [
73 gobject-introspection
74 vala
75 ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
76 mesonEmulatorHook
77 ];
78
79 buildInputs = [
80 glib
81 libxml2
82 sqlite
83 icu
84 libsoup
85 libsoup_3
86 libuuid
87 json-glib
88 libstemmer
89 dbus
90 ] ++ lib.optionals stdenv.isLinux [
91 systemd
92 ];
93
94 nativeCheckInputs = [
95 dbus
96 ];
97
98 mesonFlags = [
99 "-Ddocs=true"
100 (lib.mesonEnable "introspection" withIntrospection)
101 (lib.mesonEnable "vapi" withIntrospection)
102 (lib.mesonBool "test_utils" withIntrospection)
103 ] ++ (
104 let
105 # https://gitlab.gnome.org/GNOME/tracker/-/blob/master/meson.build#L159
106 crossFile = writeText "cross-file.conf" ''
107 [properties]
108 sqlite3_has_fts5 = '${lib.boolToString (lib.hasInfix "-DSQLITE_ENABLE_FTS3" sqlite.NIX_CFLAGS_COMPILE)}'
109 '';
110 in
111 [
112 "--cross-file=${crossFile}"
113 ]
114 ) ++ lib.optionals (!stdenv.isLinux) [
115 "-Dsystemd_user_services=false"
116 ];
117
118 doCheck =
119 # https://gitlab.gnome.org/GNOME/tracker/-/issues/402
120 !stdenv.isDarwin
121 # https://gitlab.gnome.org/GNOME/tracker/-/issues/398
122 && !stdenv.is32bit;
123
124 postPatch = ''
125 chmod +x \
126 docs/reference/libtracker-sparql/embed-files.py \
127 docs/reference/libtracker-sparql/generate-svgs.sh
128 patchShebangs \
129 utils/data-generators/cc/generate \
130 docs/reference/libtracker-sparql/embed-files.py \
131 docs/reference/libtracker-sparql/generate-svgs.sh
132 '';
133
134 preCheck =
135 let
136 linuxDot0 = lib.optionalString stdenv.isLinux ".0";
137 darwinDot0 = lib.optionalString stdenv.isDarwin ".0";
138 extension = stdenv.hostPlatform.extensions.sharedLibrary;
139 in
140 ''
141 # (tracker-store:6194): Tracker-CRITICAL **: 09:34:07.722: Cannot initialize database: Could not open sqlite3 database:'/homeless-shelter/.cache/tracker/meta.db': unable to open database file
142 export HOME=$(mktemp -d)
143
144 # Our gobject-introspection patches make the shared library paths absolute
145 # in the GIR files. When running functional tests, the library is not yet installed,
146 # though, so we need to replace the absolute path with a local one during build.
147 # We are using a symlink that will be overridden during installation.
148 mkdir -p $out/lib
149 ln -s $PWD/src/libtracker-sparql/libtracker-sparql-3.0${darwinDot0}${extension} $out/lib/libtracker-sparql-3.0${darwinDot0}${extension}${linuxDot0}
150 '';
151
152 checkPhase = ''
153 runHook preCheck
154
155 dbus-run-session \
156 --config-file=${dbus}/share/dbus-1/session.conf \
157 meson test \
158 --timeout-multiplier 2 \
159 --print-errorlogs
160
161 runHook postCheck
162 '';
163
164 postCheck = ''
165 # Clean up out symlinks
166 rm -r $out/lib
167 '';
168
169 postFixup = ''
170 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
171 moveToOutput "share/doc" "$devdoc"
172 '';
173
174 passthru = {
175 updateScript = gnome.updateScript {
176 packageName = pname;
177 };
178 };
179
180 meta = with lib; {
181 homepage = "https://wiki.gnome.org/Projects/Tracker";
182 description = "Desktop-neutral user information store, search tool and indexer";
183 maintainers = teams.gnome.members;
184 license = licenses.gpl2Plus;
185 platforms = platforms.unix;
186 };
187}