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