14 gsettings-desktop-schemas,
24 gobject-introspection,
32 enableGeoLocation ? true,
36 stdenv.mkDerivation (finalAttrs: {
37 pname = "xdg-desktop-portal";
45 src = fetchFromGitHub {
47 repo = "xdg-desktop-portal";
48 rev = finalAttrs.version;
49 hash = "sha256-o+aO7uGewDPrtgOgmp/CE2uiqiBLyo07pVCFrtlORFQ=";
53 # The icon validator copied from Flatpak needs to access the gdk-pixbuf loaders
54 # in the Nix store and cannot bind FHS paths since those are not available on NixOS.
55 (runCommand "icon-validator.patch" { } ''
56 # Flatpak uses a different path
57 substitute "${flatpak.icon-validator-patch}" "$out" \
58 --replace "/icon-validator/validate-icon.c" "/src/validate-icon.c"
61 # Allow installing installed tests to a separate output.
62 ./installed-tests-path.patch
64 # Look for portal definitions under path from `NIX_XDG_DESKTOP_PORTAL_DIR` environment variable.
65 # While upstream has `XDG_DESKTOP_PORTAL_DIR`, it is meant for tests and actually blocks
66 # any configs from being loaded from anywhere else.
67 ./nix-pkgdatadir-env.patch
69 # test tries to read /proc/cmdline, which is not intended to be accessible in the sandbox
72 # Install files required to be in XDG_DATA_DIR of the installed tests
73 # Merged PR https://github.com/flatpak/xdg-desktop-portal/pull/1444
74 ./installed-tests-share.patch
81 docutils # for rst2man
96 gsettings-desktop-schemas
105 # For document-fuse installed test.
106 (python3.withPackages (
113 ++ lib.optionals enableGeoLocation [
116 ++ lib.optionals enableSystemd [
117 systemdMinimal # libsystemd
120 nativeCheckInputs = [
121 gobject-introspection
123 python3.pkgs.python-dbusmock
124 python3.pkgs.pygobject3
125 python3.pkgs.dbus-python
131 "-Dinstalled-tests=true"
132 "-Dinstalled_test_prefix=${placeholder "installedTests"}"
133 (lib.mesonEnable "systemd" enableSystemd)
135 ++ lib.optionals (!enableGeoLocation) [
138 ++ lib.optionals (!finalAttrs.finalPackage.doCheck) [
147 # until/unless bubblewrap ships a pkg-config file, meson has no way to find it when cross-compiling.
148 substituteInPlace meson.build \
149 --replace-fail "find_program('bwrap'" "find_program('${lib.getExe bubblewrap}'"
151 # Disable test failing with libportal 0.9.0
153 assert (lib.versionOlder finalAttrs.version "1.20.0");
154 "# TODO: Remove when updating to x-d-p 1.20.0"
156 substituteInPlace tests/test-portals.c \
157 --replace-fail 'g_test_add_func ("/portal/notification/bad-arg", test_notification_bad_arg);' ""
161 # For test_trash_file
162 export HOME=$(mktemp -d)
164 # Upstream disables a few tests in CI upstream as they are known to
165 # be flaky. Let's disable those downstream as hydra exhibits similar
167 # https://github.com/NixOS/nixpkgs/pull/270085#issuecomment-1840053951
173 documentFuse = "${placeholder "installedTests"}/libexec/installed-tests/xdg-desktop-portal/test-document-fuse.py";
174 testPortals = "${placeholder "installedTests"}/libexec/installed-tests/xdg-desktop-portal/test-portals";
178 if [ -x '${documentFuse}' ] ; then
179 wrapGApp '${documentFuse}'
180 wrapGApp '${testPortals}'
181 # (xdg-desktop-portal:995): xdg-desktop-portal-WARNING **: 21:21:55.673: Failed to get GeoClue client: Timeout was reached
182 # xdg-desktop-portal:ERROR:../tests/location.c:22:location_cb: 'res' should be TRUE
183 # https://github.com/flatpak/xdg-desktop-portal/blob/1d6dfb57067dec182b546dfb60c87aa3452c77ed/tests/location.c#L21
184 rm $installedTests/share/installed-tests/xdg-desktop-portal/test-portals-location.test
190 installedTests = nixosTests.installed-tests.xdg-desktop-portal;
192 validate-icon = runCommand "test-icon-validation" { } ''
193 ${finalAttrs.finalPackage}/libexec/xdg-desktop-portal-validate-icon --sandbox 512 512 ${../../../applications/audio/zynaddsubfx/ZynLogo.svg} > "$out"
194 grep format=svg "$out"
200 description = "Desktop integration portals for sandboxed apps";
201 homepage = "https://flatpak.github.io/xdg-desktop-portal/";
202 license = licenses.lgpl2Plus;
203 maintainers = with maintainers; [ jtojnar ];
204 platforms = platforms.linux;