nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv
2, fetchurl
3, fetchpatch
4, autoconf
5, automake
6, libtool
7, docbook_xml_dtd_412
8, docbook_xml_dtd_42
9, docbook_xml_dtd_43
10, docbook-xsl-nons
11, which
12, libxml2
13, gobject-introspection
14, gtk-doc
15, intltool
16, libxslt
17, pkg-config
18, xmlto
19, appstream-glib
20, substituteAll
21, yacc
22, xdg-dbus-proxy
23, p11-kit
24, bubblewrap
25, bzip2
26, dbus
27, glib
28, gpgme
29, json-glib
30, libarchive
31, libcap
32, libseccomp
33, coreutils
34, socat
35, gettext
36, hicolor-icon-theme
37, shared-mime-info
38, desktop-file-utils
39, gtk3
40, fuse
41, nixosTests
42, libsoup
43, lzma
44, zstd
45, ostree
46, polkit
47, python3
48, systemd
49, xorg
50, valgrind
51, glib-networking
52, wrapGAppsHook
53, dconf
54, gsettings-desktop-schemas
55, librsvg
56}:
57
58stdenv.mkDerivation rec {
59 pname = "flatpak";
60 version = "1.8.1";
61
62 # TODO: split out lib once we figure out what to do with triggerdir
63 outputs = [ "out" "dev" "man" "doc" "devdoc" "installedTests" ];
64
65 src = fetchurl {
66 url = "https://github.com/flatpak/flatpak/releases/download/${version}/${pname}-${version}.tar.xz";
67 sha256 = "ZpFLZvmmQHk4bMCXpAoZ+oQZVo33+0VvLkB/D3asnq0=";
68 };
69
70 patches = [
71 # Hardcode paths used by tests and change test runtime generation to use files from Nix store.
72 # https://github.com/flatpak/flatpak/issues/1460
73 (substituteAll {
74 src = ./fix-test-paths.patch;
75 inherit coreutils gettext socat gtk3;
76 smi = shared-mime-info;
77 dfu = desktop-file-utils;
78 hicolorIconTheme = hicolor-icon-theme;
79 })
80
81 # Hardcode paths used by Flatpak itself.
82 (substituteAll {
83 src = ./fix-paths.patch;
84 p11kit = "${p11-kit.dev}/bin/p11-kit";
85 })
86
87 # Adapt paths exposed to sandbox for NixOS.
88 (substituteAll {
89 src = ./bubblewrap-paths.patch;
90 inherit (builtins) storeDir;
91 })
92
93 # Allow gtk-doc to find schemas using XML_CATALOG_FILES environment variable.
94 # Patch taken from gtk-doc expression.
95 ./respect-xml-catalog-files-var.patch
96
97 # Don’t hardcode flatpak binary path in launchers stored under user’s profile otherwise they will break after Flatpak update.
98 # https://github.com/NixOS/nixpkgs/issues/43581
99 ./use-flatpak-from-path.patch
100
101 # Nix environment hacks should not leak into the apps.
102 # https://github.com/NixOS/nixpkgs/issues/53441
103 ./unset-env-vars.patch
104
105 # But we want the GDK_PIXBUF_MODULE_FILE from the wrapper affect the icon validator.
106 ./validate-icon-pixbuf.patch
107
108 # Fix `flatpak/test-oci-registry@{user,system}.wrap.test` installed tests.
109 # https://github.com/flatpak/flatpak/pull/3762
110 (fetchpatch {
111 url = "https://github.com/flatpak/flatpak/commit/c1447dadecd50f384b6d11dac18b014245267d00.patch";
112 sha256 = "UAA/wGr8/aMbx5MV+8Ilro2kgKkx2QOn88lDUjCgeDA=";
113 })
114 ];
115
116 nativeBuildInputs = [
117 autoconf
118 automake
119 libtool
120 libxml2
121 # TODO: replace with docbook_xml_dtd_45 https://github.com/flatpak/flatpak/pull/3760
122 docbook_xml_dtd_412
123 docbook_xml_dtd_42
124 docbook_xml_dtd_43
125 docbook-xsl-nons
126 which
127 gobject-introspection
128 gtk-doc
129 intltool
130 libxslt
131 pkg-config
132 xmlto
133 appstream-glib
134 yacc
135 wrapGAppsHook
136 ];
137
138 buildInputs = [
139 bubblewrap
140 bzip2
141 dbus
142 dconf
143 gpgme
144 json-glib
145 libarchive
146 libcap
147 libseccomp
148 libsoup
149 lzma
150 # zstd # TODO: broken paths in .pc file
151 polkit
152 python3
153 systemd
154 xorg.libXau
155 fuse
156 gsettings-desktop-schemas
157 glib-networking
158 librsvg # for flatpak-validate-icon
159 ];
160
161 # Required by flatpak.pc
162 propagatedBuildInputs = [
163 glib
164 ostree
165 ];
166
167 checkInputs = [
168 valgrind
169 ];
170
171 # TODO: some issues with temporary files
172 doCheck = false;
173
174 NIX_LDFLAGS = "-lpthread";
175
176 enableParallelBuilding = true;
177
178 configureFlags = [
179 "--with-system-bubblewrap=${bubblewrap}/bin/bwrap"
180 "--with-system-dbus-proxy=${xdg-dbus-proxy}/bin/xdg-dbus-proxy"
181 "--with-dbus-config-dir=${placeholder "out"}/share/dbus-1/system.d"
182 "--localstatedir=/var"
183 "--enable-gtk-doc"
184 "--enable-installed-tests"
185 ];
186
187 makeFlags = [
188 "installed_testdir=${placeholder "installedTests"}/libexec/installed-tests/flatpak"
189 "installed_test_metadir=${placeholder "installedTests"}/share/installed-tests/flatpak"
190 ];
191
192 postPatch = let
193 vsc-py = python3.withPackages (pp: [
194 pp.pyparsing
195 ]);
196 in ''
197 patchShebangs buildutil
198 patchShebangs tests
199 PATH=${stdenv.lib.makeBinPath [vsc-py]}:$PATH patchShebangs --build variant-schema-compiler/variant-schema-compiler
200 '';
201
202 preConfigure = ''
203 # TODO: remove the condition once autogen.sh is shipped in the tarball
204 # https://github.com/flatpak/flatpak/pull/3761
205 if [[ -f autogen.sh ]]; then
206 NOCONFIGURE=1 ./autogen.sh
207 else
208 autoreconf --install --force --verbose
209 fi
210 '';
211
212 passthru = {
213 tests = {
214 installedTests = nixosTests.installed-tests.flatpak;
215 };
216 };
217
218 meta = with stdenv.lib; {
219 description = "Linux application sandboxing and distribution framework";
220 homepage = "https://flatpak.org/";
221 license = licenses.lgpl21;
222 maintainers = with maintainers; [ jtojnar ];
223 platforms = platforms.linux;
224 };
225}