1{ lib
2, stdenv
3, substituteAll
4, fetchFromGitHub
5, meson
6, mesonEmulatorHook
7, appstream
8, ninja
9, pkg-config
10, cmake
11, gettext
12, xmlto
13, docbook-xsl-nons
14, docbook_xml_dtd_45
15, libxslt
16, libstemmer
17, glib
18, xapian
19, libxml2
20, libxmlb
21, libyaml
22, gobject-introspection
23, pcre
24, itstool
25, gperf
26, vala
27, curl
28, cairo
29, gdk-pixbuf
30, pango
31, librsvg
32, systemd
33, nixosTests
34, testers
35, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
36}:
37
38stdenv.mkDerivation (finalAttrs: {
39 pname = "appstream";
40 version = "1.0.3";
41
42 outputs = [ "out" "dev" "installedTests" ];
43
44 src = fetchFromGitHub {
45 owner = "ximion";
46 repo = "appstream";
47 rev = "v${finalAttrs.version}";
48 sha256 = "sha256-pniZq+rR9wW86QqfRw4WZiBo1F16aSAb1J2RjI4aqE0=";
49 };
50
51 patches = [
52 # Fix hardcoded paths
53 (substituteAll {
54 src = ./fix-paths.patch;
55 libstemmer_includedir = "${lib.getDev libstemmer}/include";
56 })
57
58 # Allow installing installed tests to a separate output.
59 ./installed-tests-path.patch
60 ];
61
62 strictDeps = true;
63
64 depsBuildBuild = [
65 pkg-config
66 ];
67
68 nativeBuildInputs = [
69 meson
70 ninja
71 pkg-config
72 cmake
73 gettext
74 libxslt
75 xmlto
76 docbook-xsl-nons
77 docbook_xml_dtd_45
78 gobject-introspection
79 itstool
80 vala
81 gperf
82 ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
83 mesonEmulatorHook
84 appstream
85 ];
86
87 buildInputs = [
88 libstemmer
89 pcre
90 glib
91 xapian
92 libxml2
93 libxmlb
94 libyaml
95 curl
96 cairo
97 gdk-pixbuf
98 pango
99 librsvg
100 ] ++ lib.optionals withSystemd [
101 systemd
102 ];
103
104 mesonFlags = [
105 "-Dapidocs=false"
106 "-Ddocs=false"
107 "-Dvapi=true"
108 "-Dinstalled_test_prefix=${placeholder "installedTests"}"
109 "-Dcompose=true"
110 ] ++ lib.optionals (!withSystemd) [
111 "-Dsystemd=false"
112 ];
113
114 passthru.tests = {
115 installed-tests = nixosTests.installed-tests.appstream;
116 pkg-config = testers.hasPkgConfigModules {
117 package = finalAttrs.finalPackage;
118 };
119 };
120
121 meta = with lib; {
122 description = "Software metadata handling library";
123 longDescription = ''
124 AppStream is a cross-distro effort for building Software-Center applications
125 and enhancing metadata provided by software components. It provides
126 specifications for meta-information which is shipped by upstream projects and
127 can be consumed by other software.
128 '';
129 homepage = "https://www.freedesktop.org/wiki/Distributions/AppStream/";
130 license = licenses.lgpl21Plus;
131 mainProgram = "appstreamcli";
132 platforms = platforms.unix;
133 pkgConfigModules = [ "appstream" ];
134 };
135})