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