1{
2 lib,
3 stdenv,
4 fetchurl,
5 replaceVars,
6 nixosTests,
7
8 docbook_xml_dtd_45,
9 docbook_xsl,
10 gettext,
11 libxml2,
12 libxslt,
13 pkg-config,
14 xmlto,
15 meson,
16 ninja,
17
18 acl,
19 appstream,
20 breezy,
21 binutils,
22 bzip2,
23 coreutils,
24 cpio,
25 curl,
26 debugedit,
27 elfutils,
28 flatpak,
29 gitMinimal,
30 glib,
31 glibcLocales,
32 gnumake,
33 gnupg,
34 gnutar,
35 json-glib,
36 libcap,
37 libyaml,
38 ostree,
39 patch,
40 rpm,
41 unzip,
42 attr,
43}:
44
45stdenv.mkDerivation (finalAttrs: {
46 pname = "flatpak-builder";
47 version = "1.4.4";
48
49 outputs = [
50 "out"
51 "doc"
52 "man"
53 "installedTests"
54 ];
55
56 # fetchFromGitHub fetches an archive which does not contain the full source (https://github.com/flatpak/flatpak-builder/issues/558)
57 src = fetchurl {
58 url = "https://github.com/flatpak/flatpak-builder/releases/download/${finalAttrs.version}/flatpak-builder-${finalAttrs.version}.tar.xz";
59 hash = "sha256-3CcVk5S6qiy1I/Uvh0Ry/1DRYZgyMyZMoqIuhQdB7Ho=";
60 };
61
62 patches = [
63 # patch taken from gtk_doc
64 ./respect-xml-catalog-files-var.patch
65
66 # Hardcode paths
67 (replaceVars ./fix-paths.patch {
68 brz = "${breezy}/bin/brz";
69 cp = "${coreutils}/bin/cp";
70 patch = "${patch}/bin/patch";
71 tar = "${gnutar}/bin/tar";
72 unzip = "${unzip}/bin/unzip";
73 rpm2cpio = "${rpm}/bin/rpm2cpio";
74 cpio = "${cpio}/bin/cpio";
75 git = "${gitMinimal}/bin/git";
76 rofilesfuse = "${ostree}/bin/rofiles-fuse";
77 strip = "${binutils}/bin/strip";
78 eustrip = "${elfutils}/bin/eu-strip";
79 euelfcompress = "${elfutils}/bin/eu-elfcompress";
80 })
81
82 (replaceVars ./fix-test-paths.patch {
83 inherit glibcLocales;
84 })
85 ./fix-test-prefix.patch
86 ];
87
88 nativeBuildInputs = [
89 meson
90 ninja
91 docbook_xml_dtd_45
92 docbook_xsl
93 gettext
94 libxml2
95 libxslt
96 pkg-config
97 xmlto
98 ];
99
100 buildInputs = [
101 acl
102 appstream
103 bzip2
104 curl
105 debugedit
106 elfutils
107 flatpak
108 glib
109 json-glib
110 libcap
111 libxml2
112 libyaml
113 ostree
114 ];
115
116 mesonFlags = [
117 "-Dinstalled_tests=true"
118 "-Dinstalled_test_prefix=${placeholder "installedTests"}"
119 ];
120
121 # Some scripts used by tests need to use shebangs that are available in Flatpak runtimes.
122 dontPatchShebangs = true;
123
124 enableParallelBuilding = true;
125
126 # Installed tests
127 postFixup =
128 let
129 installed_testdir = "${placeholder "installedTests"}/libexec/installed-tests/flatpak-builder";
130 in
131 ''
132 for file in ${installed_testdir}/{test-builder.sh,test-builder-python.sh,test-builder-deprecated.sh}; do
133 patchShebangs $file
134 done
135 '';
136
137 passthru = {
138 installedTestsDependencies = [
139 gnupg
140 ostree
141 gnumake
142 attr
143 libxml2
144 appstream
145 ];
146
147 tests = {
148 installedTests = nixosTests.installed-tests.flatpak-builder;
149 };
150 };
151
152 meta = with lib; {
153 description = "Tool to build flatpaks from source";
154 mainProgram = "flatpak-builder";
155 homepage = "https://github.com/flatpak/flatpak-builder";
156 license = licenses.lgpl21Plus;
157 maintainers = with maintainers; [ arthsmn ];
158 platforms = platforms.linux;
159 };
160})