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
78 url = "https://github.com/flatpak/flatpak/releases/download/${finalAttrs.version}/flatpak-${finalAttrs.version}.tar.xz";
79 hash = "sha256-a73HkIEnNQrYWkpH1wKSyi9MRul3sysf0jHCpxnYIc0=";
83 # Hardcode paths used by tests and change test runtime generation to use files from Nix store.
84 # https://github.com/flatpak/flatpak/issues/1460
86 src = ./fix-test-paths.patch;
93 smi = shared-mime-info;
94 dfu = desktop-file-utils;
95 hicolorIconTheme = hicolor-icon-theme;
98 # Hardcode paths used by Flatpak itself.
100 src = ./fix-paths.patch;
101 p11kit = "${p11-kit.bin}/bin/p11-kit";
104 # Allow gtk-doc to find schemas using XML_CATALOG_FILES environment variable.
105 # Patch taken from gtk-doc expression.
106 ./respect-xml-catalog-files-var.patch
108 # Nix environment hacks should not leak into the apps.
109 # https://github.com/NixOS/nixpkgs/issues/53441
110 ./unset-env-vars.patch
112 # Use flatpak from PATH to avoid references to `/nix/store` in `/desktop` files.
113 # Applications containing `DBusActivatable` entries should be able to find the flatpak binary.
114 # https://github.com/NixOS/nixpkgs/issues/138956
117 # The icon validator needs to access the gdk-pixbuf loaders in the Nix store
118 # and cannot bind FHS paths since those are not available on NixOS.
119 finalAttrs.passthru.icon-validator-patch
121 # Try mounting fonts and icons from NixOS locations if FHS locations don't exist.
122 # https://github.com/NixOS/nixpkgs/issues/119433
123 ./fix-fonts-icons.patch
125 # TODO: Remove when updating to 1.16
126 # Ensure flatpak uses the system's zoneinfo from $TZDIR
127 # https://github.com/NixOS/nixpkgs/issues/238386
129 url = "https://github.com/flatpak/flatpak/pull/5850/commits/a8a35bf4d9fc3d76e1a5049a6a591faec04a42fd.patch";
130 hash = "sha256-JqkPbnzgZNZq/mplZqohhHFdjRrvYFjE4C02pI3feBo=";
133 url = "https://github.com/flatpak/flatpak/pull/5850/commits/5ea13b09612215559081c27b60df4fb720cb08d5.patch";
134 hash = "sha256-BWbyQ2en3RtN4Ec5n62CULAhvywlQLhcl3Fmd4fsR1s=";
137 url = "https://github.com/flatpak/flatpak/pull/5850/commits/7c8a81f08908019bbf69358de199748a9bcb29e3.patch";
138 hash = "sha256-RiG2jPmG+Igskxv8oQquOUYsG4srgdMXWe34ojMXslo=";
142 nativeBuildInputs = [
148 gobject-introspection
178 gsettings-desktop-schemas
180 librsvg # for flatpak-validate-icon
181 ] ++ lib.optionals withGtkDoc [ gtk-doc ];
183 # Required by flatpak.pc
184 propagatedBuildInputs = [
189 nativeCheckInputs = [ valgrind ];
191 # TODO: some issues with temporary files
195 NIX_LDFLAGS = "-lpthread";
197 enableParallelBuilding = true;
201 "--with-system-bubblewrap=${lib.getExe bubblewrap}"
202 "--with-system-dbus-proxy=${lib.getExe xdg-dbus-proxy}"
203 "--with-dbus-config-dir=${placeholder "out"}/share/dbus-1/system.d"
204 "--with-profile-dir=${placeholder "out"}/etc/profile.d"
205 "--localstatedir=/var"
207 "--enable-gtk-doc=${if withGtkDoc then "yes" else "no"}"
208 "--enable-installed-tests"
209 "--enable-selinux-module=no"
213 "installed_testdir=${placeholder "installedTests"}/libexec/installed-tests/flatpak"
214 "installed_test_metadir=${placeholder "installedTests"}/share/installed-tests/flatpak"
219 vsc-py = python3.pythonOnBuildForHost.withPackages (pp: [ pp.pyparsing ]);
222 patchShebangs buildutil
224 PATH=${lib.makeBinPath [ vsc-py ]}:$PATH patchShebangs --build subprojects/variant-schema-compiler/variant-schema-compiler
226 substituteInPlace configure.ac \
227 --replace-fail '$BWRAP --' ${
228 lib.escapeShellArg (stdenv.hostPlatform.emulator buildPackages + " $BWRAP --")
230 --replace-fail '$DBUS_PROXY --' ${
231 lib.escapeShellArg (stdenv.hostPlatform.emulator buildPackages + " $DBUS_PROXY --")
236 icon-validator-patch = substituteAll {
237 src = ./fix-icon-validation.patch;
238 inherit (builtins) storeDir;
241 updateScript = nix-update-script { };
244 cross = pkgsCross.aarch64-multiplatform.flatpak;
246 installedTests = nixosTests.installed-tests.flatpak;
248 validate-icon = runCommand "test-icon-validation" { } ''
249 ${finalAttrs.finalPackage}/libexec/flatpak-validate-icon \
251 "${nixos-icons}/share/icons/hicolor/512x512/apps/nix-snowflake.png" > "$out"
253 grep format=png "$out"
256 version = testers.testVersion { package = finalAttrs.finalPackage; };
261 description = "Linux application sandboxing and distribution framework";
262 homepage = "https://flatpak.org/";
263 changelog = "https://github.com/flatpak/flatpak/releases/tag/${finalAttrs.version}";
264 license = lib.licenses.lgpl21Plus;
265 maintainers = with lib.maintainers; [ getchoo ];
266 platforms = lib.platforms.linux;