1{ stdenv
2, lib
3, fetchurl
4, glib
5, meson
6, ninja
7, pkg-config
8, gettext
9, libxslt
10, python3
11, docbook-xsl-nons
12, docbook_xml_dtd_42
13, libgcrypt
14, gobject-introspection
15, buildPackages
16, withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages
17, vala
18, gi-docgen
19, gnome
20, gjs
21, libintl
22, dbus
23}:
24
25stdenv.mkDerivation rec {
26 pname = "libsecret";
27 version = "0.20.5";
28
29 outputs = [ "out" "dev" ] ++ lib.optional withIntrospection "devdoc";
30
31 src = fetchurl {
32 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
33 sha256 = "P7PONA/NfbVNh8iT5pv8Kx9uTUsnkGX/5m2snw/RK00=";
34 };
35
36 depsBuildBuild = [
37 pkg-config
38 ];
39
40 nativeBuildInputs = [
41 meson
42 ninja
43 pkg-config
44 gettext
45 libxslt # for xsltproc for building man pages
46 docbook-xsl-nons
47 docbook_xml_dtd_42
48 libintl
49 vala
50 glib
51 ] ++ lib.optionals withIntrospection [
52 gi-docgen
53 gobject-introspection
54 ];
55
56 buildInputs = [
57 libgcrypt
58 ];
59
60 propagatedBuildInputs = [
61 glib
62 ];
63
64 nativeCheckInputs = [
65 python3
66 python3.pkgs.dbus-python
67 python3.pkgs.pygobject3
68 dbus
69 gjs
70 ];
71
72 mesonFlags = [
73 (lib.mesonBool "introspection" withIntrospection)
74 (lib.mesonBool "gtk_doc" withIntrospection)
75 ];
76
77 doCheck = stdenv.isLinux && withIntrospection;
78 separateDebugInfo = true;
79
80 postPatch = ''
81 patchShebangs ./tool/test-*.sh
82 '';
83
84 preCheck = ''
85 # Our gobject-introspection patches make the shared library paths absolute
86 # in the GIR files. When running tests, the library is not yet installed,
87 # though, so we need to replace the absolute path with a local one during build.
88 # We are using a symlink that will be overwitten during installation.
89 mkdir -p $out/lib $out/lib
90 ln -s "$PWD/libsecret/libmock-service.so" "$out/lib/libmock-service.so"
91 ln -s "$PWD/libsecret/libsecret-1.so.0" "$out/lib/libsecret-1.so.0"
92 '';
93
94 checkPhase = ''
95 runHook preCheck
96
97 dbus-run-session \
98 --config-file=${dbus}/share/dbus-1/session.conf \
99 meson test --print-errorlogs --timeout-multiplier 0
100
101 runHook postCheck
102 '';
103
104 postCheck = ''
105 # This is test-only so it won’t be overwritten during installation.
106 rm "$out/lib/libmock-service.so"
107 '';
108
109 postFixup = ''
110 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
111 moveToOutput "share/doc" "$devdoc"
112 '';
113
114 passthru = {
115 updateScript = gnome.updateScript {
116 packageName = pname;
117 # Does not seem to use the odd-unstable policy: https://gitlab.gnome.org/GNOME/libsecret/issues/30
118 versionPolicy = "none";
119 };
120 };
121
122 meta = {
123 description = "A library for storing and retrieving passwords and other secrets";
124 homepage = "https://wiki.gnome.org/Projects/Libsecret";
125 license = lib.licenses.lgpl21Plus;
126 mainProgram = "secret-tool";
127 inherit (glib.meta) platforms maintainers;
128 };
129}