zipline: refactor environment variables (#377101)
[NixPkgs.git] / pkgs / by-name / fl / flatpak / package.nix
blob7d31297d22b23ae22ec5ca9773785a8ccf00ca23
2   lib,
3   stdenv,
4   fetchurl,
5   fetchpatch,
6   runCommand,
7   appstream,
8   autoreconfHook,
9   bison,
10   bubblewrap,
11   buildPackages,
12   bzip2,
13   coreutils,
14   curl,
15   dbus,
16   dconf,
17   desktop-file-utils,
18   docbook_xml_dtd_45,
19   docbook-xsl-nons,
20   fuse3,
21   gettext,
22   glib,
23   glib-networking,
24   gobject-introspection,
25   gpgme,
26   gsettings-desktop-schemas,
27   gtk3,
28   gtk-doc,
29   hicolor-icon-theme,
30   intltool,
31   json-glib,
32   libarchive,
33   libcap,
34   librsvg,
35   libseccomp,
36   libxml2,
37   libxslt,
38   nix-update-script,
39   nixosTests,
40   nixos-icons,
41   ostree,
42   p11-kit,
43   pkg-config,
44   polkit,
45   pkgsCross,
46   python3,
47   shared-mime-info,
48   socat,
49   substituteAll,
50   systemd,
51   testers,
52   valgrind,
53   which,
54   wrapGAppsNoGuiHook,
55   xdg-dbus-proxy,
56   xmlto,
57   xorg,
58   xz,
59   zstd,
60   withGtkDoc ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
63 stdenv.mkDerivation (finalAttrs: {
64   pname = "flatpak";
65   version = "1.14.10";
67   # TODO: split out lib once we figure out what to do with triggerdir
68   outputs = [
69     "out"
70     "dev"
71     "man"
72     "doc"
73     "devdoc"
74     "installedTests"
75   ];
77   separateDebugInfo = true;
79   src = fetchurl {
80     url = "https://github.com/flatpak/flatpak/releases/download/${finalAttrs.version}/flatpak-${finalAttrs.version}.tar.xz";
81     hash = "sha256-a73HkIEnNQrYWkpH1wKSyi9MRul3sysf0jHCpxnYIc0=";
82   };
84   patches = [
85     # Hardcode paths used by tests and change test runtime generation to use files from Nix store.
86     # https://github.com/flatpak/flatpak/issues/1460
87     (substituteAll {
88       src = ./fix-test-paths.patch;
89       inherit
90         coreutils
91         gettext
92         socat
93         gtk3
94         ;
95       smi = shared-mime-info;
96       dfu = desktop-file-utils;
97       hicolorIconTheme = hicolor-icon-theme;
98     })
100     # Hardcode paths used by Flatpak itself.
101     (substituteAll {
102       src = ./fix-paths.patch;
103       p11kit = "${p11-kit.bin}/bin/p11-kit";
104     })
106     # Allow gtk-doc to find schemas using XML_CATALOG_FILES environment variable.
107     # Patch taken from gtk-doc expression.
108     ./respect-xml-catalog-files-var.patch
110     # Nix environment hacks should not leak into the apps.
111     # https://github.com/NixOS/nixpkgs/issues/53441
112     ./unset-env-vars.patch
114     # Use flatpak from PATH to avoid references to `/nix/store` in `/desktop` files.
115     # Applications containing `DBusActivatable` entries should be able to find the flatpak binary.
116     # https://github.com/NixOS/nixpkgs/issues/138956
117     ./binary-path.patch
119     # The icon validator needs to access the gdk-pixbuf loaders in the Nix store
120     # and cannot bind FHS paths since those are not available on NixOS.
121     finalAttrs.passthru.icon-validator-patch
123     # Try mounting fonts and icons from NixOS locations if FHS locations don't exist.
124     # https://github.com/NixOS/nixpkgs/issues/119433
125     ./fix-fonts-icons.patch
127     # TODO: Remove when updating to 1.16
128     # Ensure flatpak uses the system's zoneinfo from $TZDIR
129     # https://github.com/NixOS/nixpkgs/issues/238386
130     (fetchpatch {
131       url = "https://github.com/flatpak/flatpak/pull/5850/commits/a8a35bf4d9fc3d76e1a5049a6a591faec04a42fd.patch";
132       hash = "sha256-JqkPbnzgZNZq/mplZqohhHFdjRrvYFjE4C02pI3feBo=";
133     })
134     (fetchpatch {
135       url = "https://github.com/flatpak/flatpak/pull/5850/commits/5ea13b09612215559081c27b60df4fb720cb08d5.patch";
136       hash = "sha256-BWbyQ2en3RtN4Ec5n62CULAhvywlQLhcl3Fmd4fsR1s=";
137     })
138     (fetchpatch {
139       url = "https://github.com/flatpak/flatpak/pull/5850/commits/7c8a81f08908019bbf69358de199748a9bcb29e3.patch";
140       hash = "sha256-RiG2jPmG+Igskxv8oQquOUYsG4srgdMXWe34ojMXslo=";
141     })
142   ];
144   nativeBuildInputs = [
145     autoreconfHook
146     libxml2
147     docbook_xml_dtd_45
148     docbook-xsl-nons
149     which
150     gobject-introspection
151     gtk-doc
152     intltool
153     libxslt
154     pkg-config
155     xmlto
156     bison
157     wrapGAppsNoGuiHook
158   ];
160   buildInputs = [
161     appstream
162     bubblewrap
163     bzip2
164     curl
165     dbus
166     dconf
167     gpgme
168     json-glib
169     libarchive
170     libcap
171     libseccomp
172     libxml2
173     xz
174     zstd
175     polkit
176     python3
177     systemd
178     xorg.libXau
179     fuse3
180     gsettings-desktop-schemas
181     glib-networking
182     librsvg # for flatpak-validate-icon
183   ] ++ lib.optionals withGtkDoc [ gtk-doc ];
185   # Required by flatpak.pc
186   propagatedBuildInputs = [
187     glib
188     ostree
189   ];
191   nativeCheckInputs = [ valgrind ];
193   # TODO: some issues with temporary files
194   doCheck = false;
195   strictDeps = true;
197   NIX_LDFLAGS = "-lpthread";
199   enableParallelBuilding = true;
201   configureFlags = [
202     "--with-curl"
203     "--with-system-bubblewrap=${lib.getExe bubblewrap}"
204     "--with-system-dbus-proxy=${lib.getExe xdg-dbus-proxy}"
205     "--with-dbus-config-dir=${placeholder "out"}/share/dbus-1/system.d"
206     "--with-profile-dir=${placeholder "out"}/etc/profile.d"
207     "--localstatedir=/var"
208     "--sysconfdir=/etc"
209     "--enable-gtk-doc=${if withGtkDoc then "yes" else "no"}"
210     "--enable-installed-tests"
211     "--enable-selinux-module=no"
212   ];
214   makeFlags = [
215     "installed_testdir=${placeholder "installedTests"}/libexec/installed-tests/flatpak"
216     "installed_test_metadir=${placeholder "installedTests"}/share/installed-tests/flatpak"
217   ];
219   postPatch =
220     let
221       vsc-py = python3.pythonOnBuildForHost.withPackages (pp: [ pp.pyparsing ]);
222     in
223     ''
224       patchShebangs buildutil
225       patchShebangs tests
226       PATH=${lib.makeBinPath [ vsc-py ]}:$PATH patchShebangs --build subprojects/variant-schema-compiler/variant-schema-compiler
228       substituteInPlace configure.ac \
229         --replace-fail '$BWRAP --' ${
230           lib.escapeShellArg (stdenv.hostPlatform.emulator buildPackages + " $BWRAP --")
231         } \
232         --replace-fail '$DBUS_PROXY --' ${
233           lib.escapeShellArg (stdenv.hostPlatform.emulator buildPackages + " $DBUS_PROXY --")
234         }
235     '';
237   passthru = {
238     icon-validator-patch = substituteAll {
239       src = ./fix-icon-validation.patch;
240       inherit (builtins) storeDir;
241     };
243     updateScript = nix-update-script { };
245     tests = {
246       cross = pkgsCross.aarch64-multiplatform.flatpak;
248       installedTests = nixosTests.installed-tests.flatpak;
250       validate-icon = runCommand "test-icon-validation" { } ''
251         ${finalAttrs.finalPackage}/libexec/flatpak-validate-icon \
252           --sandbox 512 512 \
253           "${nixos-icons}/share/icons/hicolor/512x512/apps/nix-snowflake.png" > "$out"
255         grep format=png "$out"
256       '';
258       version = testers.testVersion { package = finalAttrs.finalPackage; };
259     };
260   };
262   meta = {
263     description = "Linux application sandboxing and distribution framework";
264     homepage = "https://flatpak.org/";
265     changelog = "https://github.com/flatpak/flatpak/releases/tag/${finalAttrs.version}";
266     license = lib.licenses.lgpl21Plus;
267     maintainers = with lib.maintainers; [ getchoo ];
268     mainProgram = "flatpak";
269     platforms = lib.platforms.linux;
270   };