diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/xdg-desktop-portal')
3 files changed, 209 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/default.nix b/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/default.nix new file mode 100644 index 000000000000..905675c40659 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/default.nix @@ -0,0 +1,146 @@ +{ lib +, fetchFromGitHub +, flatpak +, fuse3 +, bubblewrap +, docbook_xml_dtd_412 +, docbook_xml_dtd_43 +, docbook_xsl +, docutils +, systemdMinimal +, geoclue2 +, glib +, gsettings-desktop-schemas +, json-glib +, libportal +, libxml2 +, meson +, ninja +, nixosTests +, pipewire +, gdk-pixbuf +, librsvg +, python3 +, pkg-config +, stdenv +, runCommand +, wrapGAppsHook +, xmlto +, enableGeoLocation ? true +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "xdg-desktop-portal"; + version = "1.18.2"; + + outputs = [ "out" "installedTests" ]; + + src = fetchFromGitHub { + owner = "flatpak"; + repo = "xdg-desktop-portal"; + rev = finalAttrs.version; + hash = "sha256-Pd5IKrVp/OOE10Ozy4R3XbubVc6iz0znG+YB0Uu+68E="; + }; + + patches = [ + # The icon validator copied from Flatpak needs to access the gdk-pixbuf loaders + # in the Nix store and cannot bind FHS paths since those are not available on NixOS. + (runCommand "icon-validator.patch" { } '' + # Flatpak uses a different path + substitute "${flatpak.icon-validator-patch}" "$out" \ + --replace "/icon-validator/validate-icon.c" "/src/validate-icon.c" + '') + + # Allow installing installed tests to a separate output. + ./installed-tests-path.patch + + # `XDG_DESKTOP_PORTAL_DIR` originally was used for upstream tests. But we are making use + # of this in the NixOS module, this actually blocks any configs from being loaded since + # configs are not expected to be placed in a portal implementation or even under the + # `share/xdg-desktop-portal/portals/` path. + ./separate-env-for-portal-config.patch + ]; + + nativeBuildInputs = [ + docbook_xml_dtd_412 + docbook_xml_dtd_43 + docbook_xsl + docutils # for rst2man + libxml2 + meson + ninja + pkg-config + wrapGAppsHook + xmlto + ]; + + buildInputs = [ + flatpak + fuse3 + bubblewrap + systemdMinimal # libsystemd + glib + gsettings-desktop-schemas + json-glib + libportal + pipewire + + # For icon validator + gdk-pixbuf + librsvg + + # For document-fuse installed test. + (python3.withPackages (pp: with pp; [ + pygobject3 + ])) + ] ++ lib.optionals enableGeoLocation [ + geoclue2 + ]; + + nativeCheckInputs = [ + python3.pkgs.pytest + python3.pkgs.python-dbusmock + python3.pkgs.pygobject3 + python3.pkgs.dbus-python + ]; + + mesonFlags = [ + "--sysconfdir=/etc" + "-Dinstalled-tests=true" + "-Dinstalled_test_prefix=${placeholder "installedTests"}" + ] ++ lib.optionals (!enableGeoLocation) [ + "-Dgeoclue=disabled" + ]; + + doCheck = true; + + preCheck = '' + # For test_trash_file + export HOME=$(mktemp -d) + + # Upstream disables a few tests in CI upstream as they are known to + # be flaky. Let's disable those downstream as hydra exhibits similar + # flakes: + # https://github.com/NixOS/nixpkgs/pull/270085#issuecomment-1840053951 + export TEST_IN_CI=1 + ''; + + passthru = { + tests = { + installedTests = nixosTests.installed-tests.xdg-desktop-portal; + + validate-icon = runCommand "test-icon-validation" { } '' + ${finalAttrs.finalPackage}/libexec/xdg-desktop-portal-validate-icon --sandbox 512 512 ${../../../applications/audio/zynaddsubfx/ZynLogo.svg} > "$out" + grep format=svg "$out" + ''; + }; + }; + + meta = with lib; { + description = "Desktop integration portals for sandboxed apps"; + homepage = "https://flatpak.github.io/xdg-desktop-portal/"; + license = licenses.lgpl2Plus; + maintainers = with maintainers; [ jtojnar ]; + platforms = platforms.linux; + }; +}) diff --git a/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/installed-tests-path.patch b/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/installed-tests-path.patch new file mode 100644 index 000000000000..0a9547ba3628 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/installed-tests-path.patch @@ -0,0 +1,30 @@ +diff --git a/meson.build b/meson.build +index b25f9ef..7975f85 100644 +--- a/meson.build ++++ b/meson.build +@@ -40,8 +40,8 @@ if dataroot_dir == '' + dataroot_dir = datadir + endif + +-installed_tests_dir = prefix / libexecdir / 'installed-tests' / meson.project_name() +-installed_tests_data_dir = prefix / datadir / 'installed-tests' / meson.project_name() ++installed_tests_dir = get_option('installed_test_prefix') / 'libexec' / 'installed-tests' / meson.project_name() ++installed_tests_data_dir = get_option('installed_test_prefix') / 'share' / 'installed-tests' / meson.project_name() + docs_dir = datadir / 'doc' / meson.project_name() + + summary({ +diff --git a/meson_options.txt b/meson_options.txt +index fccada3..ca87600 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -38,6 +38,10 @@ option('installed-tests', + type: 'boolean', + value: false, + description: 'Enable installation of some test cases') ++option('installed_test_prefix', ++ type: 'string', ++ value: '', ++ description: 'Prefix for installed tests') + option('pytest', + type: 'feature', + value: 'auto', diff --git a/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/separate-env-for-portal-config.patch b/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/separate-env-for-portal-config.patch new file mode 100644 index 000000000000..020d98c20700 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/xdg-desktop-portal/separate-env-for-portal-config.patch @@ -0,0 +1,33 @@ +diff --git a/src/portal-impl.c b/src/portal-impl.c +index 0fa9682e..99f379dc 100644 +--- a/src/portal-impl.c ++++ b/src/portal-impl.c +@@ -433,8 +433,7 @@ load_portal_configuration (gboolean opt_verbose) + + desktops = get_current_lowercase_desktops (); + +- /* We need to override this in the tests */ +- portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); ++ portal_dir = g_getenv ("NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR_OVERRIDE"); + + if (portal_dir != NULL) + { +@@ -464,6 +463,18 @@ load_portal_configuration (gboolean opt_verbose) + if (load_config_directory (SYSCONFDIR "/" XDP_SUBDIR, desktops, opt_verbose)) + return; + ++ portal_dir = g_getenv ("NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR"); ++ ++ if (portal_dir == NULL) ++ /* We need to override this in the tests */ ++ portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); ++ ++ if (portal_dir != NULL) ++ { ++ if (load_config_directory (portal_dir, desktops, opt_verbose)) ++ return; ++ } ++ + /* $XDG_DATA_HOME/xdg-desktop-portal/(DESKTOP-)portals.conf + * (just for consistency with other XDG specifications) */ + g_clear_pointer (&user_portal_dir, g_free); |