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