24 gobject-introspection,
26 gsettings-desktop-schemas,
60 withGtkDoc ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
63 stdenv.mkDerivation (finalAttrs: {
67 # TODO: split out lib once we figure out what to do with triggerdir
77 separateDebugInfo = true;
80 url = "https://github.com/flatpak/flatpak/releases/download/${finalAttrs.version}/flatpak-${finalAttrs.version}.tar.xz";
81 hash = "sha256-a73HkIEnNQrYWkpH1wKSyi9MRul3sysf0jHCpxnYIc0=";
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
88 src = ./fix-test-paths.patch;
95 smi = shared-mime-info;
96 dfu = desktop-file-utils;
97 hicolorIconTheme = hicolor-icon-theme;
100 # Hardcode paths used by Flatpak itself.
102 src = ./fix-paths.patch;
103 p11kit = "${p11-kit.bin}/bin/p11-kit";
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
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
131 url = "https://github.com/flatpak/flatpak/pull/5850/commits/a8a35bf4d9fc3d76e1a5049a6a591faec04a42fd.patch";
132 hash = "sha256-JqkPbnzgZNZq/mplZqohhHFdjRrvYFjE4C02pI3feBo=";
135 url = "https://github.com/flatpak/flatpak/pull/5850/commits/5ea13b09612215559081c27b60df4fb720cb08d5.patch";
136 hash = "sha256-BWbyQ2en3RtN4Ec5n62CULAhvywlQLhcl3Fmd4fsR1s=";
139 url = "https://github.com/flatpak/flatpak/pull/5850/commits/7c8a81f08908019bbf69358de199748a9bcb29e3.patch";
140 hash = "sha256-RiG2jPmG+Igskxv8oQquOUYsG4srgdMXWe34ojMXslo=";
144 nativeBuildInputs = [
150 gobject-introspection
180 gsettings-desktop-schemas
182 librsvg # for flatpak-validate-icon
183 ] ++ lib.optionals withGtkDoc [ gtk-doc ];
185 # Required by flatpak.pc
186 propagatedBuildInputs = [
191 nativeCheckInputs = [ valgrind ];
193 # TODO: some issues with temporary files
197 NIX_LDFLAGS = "-lpthread";
199 enableParallelBuilding = true;
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"
209 "--enable-gtk-doc=${if withGtkDoc then "yes" else "no"}"
210 "--enable-installed-tests"
211 "--enable-selinux-module=no"
215 "installed_testdir=${placeholder "installedTests"}/libexec/installed-tests/flatpak"
216 "installed_test_metadir=${placeholder "installedTests"}/share/installed-tests/flatpak"
221 vsc-py = python3.pythonOnBuildForHost.withPackages (pp: [ pp.pyparsing ]);
224 patchShebangs buildutil
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 --")
232 --replace-fail '$DBUS_PROXY --' ${
233 lib.escapeShellArg (stdenv.hostPlatform.emulator buildPackages + " $DBUS_PROXY --")
238 icon-validator-patch = substituteAll {
239 src = ./fix-icon-validation.patch;
240 inherit (builtins) storeDir;
243 updateScript = nix-update-script { };
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 \
253 "${nixos-icons}/share/icons/hicolor/512x512/apps/nix-snowflake.png" > "$out"
255 grep format=png "$out"
258 version = testers.testVersion { package = finalAttrs.finalPackage; };
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;