Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion nixos/tests/installed-tests/xdg-desktop-portal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ makeInstalledTest {
# Failed connect to PipeWire: Couldn't connect to PipeWire
testConfig = {
environment.variables = {
TEST_IN_CI = 1;
XDP_TEST_IN_CI = 1;
XDG_DATA_DIRS = "${pkgs.xdg-desktop-portal.installedTests}/share/installed-tests/xdg-desktop-portal/share";
};
environment.systemPackages = with pkgs; [
(python3.withPackages (
pp: with pp; [
pygobject3
sphinxext-opengraph
sphinx-copybutton
furo
]
))
wireless-regdb
];
# Broken, see comment in the package file.
#services.geoclue2 = {
# enable = true;
Expand Down
70 changes: 40 additions & 30 deletions pkgs/development/libraries/xdg-desktop-portal/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@
wrapGAppsHook3,
xmlto,
bash,
gst_all_1,
libgudev,
umockdev,
sphinx,
substituteAll,
enableGeoLocation ? true,
enableSystemd ? true,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "xdg-desktop-portal";
version = "1.18.4";
version = "1.19.2";

outputs = [
"out"
Expand All @@ -45,18 +50,17 @@ stdenv.mkDerivation (finalAttrs: {
src = fetchFromGitHub {
owner = "flatpak";
repo = "xdg-desktop-portal";
rev = finalAttrs.version;
hash = "sha256-o+aO7uGewDPrtgOgmp/CE2uiqiBLyo07pVCFrtlORFQ=";
tag = finalAttrs.version;
hash = "sha256-LV9+t8VAA+gdUKzPMALP9q6EE0Y2hJe/i8zfh7Zgmu4=";
};

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"
'')
(substituteAll {
src = ./fix-icon-validation.patch;
inherit (builtins) storeDir;
})

# Allow installing installed tests to a separate output.
./installed-tests-path.patch
Expand All @@ -68,10 +72,6 @@ stdenv.mkDerivation (finalAttrs: {

# test tries to read /proc/cmdline, which is not intended to be accessible in the sandbox
./trash-test.patch

# Install files required to be in XDG_DATA_DIR of the installed tests
# Merged PR https://github.com/flatpak/xdg-desktop-portal/pull/1444
./installed-tests-share.patch
];

nativeBuildInputs = [
Expand All @@ -85,6 +85,18 @@ stdenv.mkDerivation (finalAttrs: {
pkg-config
wrapGAppsHook3
xmlto
sphinx
gst_all_1.gstreamer
gst_all_1.gst-plugins-good
# For document-fuse installed test.
(python3.withPackages (
pp: with pp; [
pygobject3
sphinxext-opengraph
sphinx-copybutton
furo
]
))
];

buildInputs =
Expand All @@ -97,17 +109,13 @@ stdenv.mkDerivation (finalAttrs: {
json-glib
libportal
pipewire
gst_all_1.gst-plugins-base
libgudev
umockdev

# For icon validator
gdk-pixbuf
librsvg

# For document-fuse installed test.
(python3.withPackages (
pp: with pp; [
pygobject3
]
))
bash
]
++ lib.optionals enableGeoLocation [
Expand Down Expand Up @@ -155,6 +163,9 @@ stdenv.mkDerivation (finalAttrs: {
}
substituteInPlace tests/test-portals.c \
--replace-fail 'g_test_add_func ("/portal/notification/bad-arg", test_notification_bad_arg);' ""

patchShebangs src/generate-method-info.py
patchShebangs doc/fix-rst-dbus.py
'';

preCheck = ''
Expand All @@ -165,23 +176,22 @@ stdenv.mkDerivation (finalAttrs: {
# 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
export XDP_TEST_IN_CI=1

export XDP_VALIDATE_SOUND_INSECURE=1 # For validate-sound: Failed to create gstreamer discoverer: Couldn't create 'uridecodebin' element

export LD_PRELOAD=$LD_PRELOAD:${lib.getLib umockdev}/lib/libumockdev-preload.so
'';

postFixup =
let
documentFuse = "${placeholder "installedTests"}/libexec/installed-tests/xdg-desktop-portal/test-document-fuse.py";
testPortals = "${placeholder "installedTests"}/libexec/installed-tests/xdg-desktop-portal/test-portals";

in
''
if [ -x '${documentFuse}' ] ; then
wrapGApp '${documentFuse}'
wrapGApp '${testPortals}'
# (xdg-desktop-portal:995): xdg-desktop-portal-WARNING **: 21:21:55.673: Failed to get GeoClue client: Timeout was reached
# xdg-desktop-portal:ERROR:../tests/location.c:22:location_cb: 'res' should be TRUE
# https://github.com/flatpak/xdg-desktop-portal/blob/1d6dfb57067dec182b546dfb60c87aa3452c77ed/tests/location.c#L21
rm $installedTests/share/installed-tests/xdg-desktop-portal/test-portals-location.test
fi
'';

Expand All @@ -196,11 +206,11 @@ stdenv.mkDerivation (finalAttrs: {
};
};

meta = with lib; {
meta = {
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;
homepage = "https://flatpak.github.io/xdg-desktop-portal";
license = lib.licenses.lgpl2Plus;
maintainers = with lib.maintainers; [ jtojnar ];
platforms = lib.platforms.linux;
};
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/src/validate-icon.c b/src/validate-icon.c
index c42265b..320f028 100644
--- a/src/validate-icon.c
+++ b/src/validate-icon.c
@@ -254,7 +254,7 @@ flatpak_get_bwrap (void)
static int
rerun_in_sandbox (int input_fd)
{
- const char * const usrmerged_dirs[] = { "bin", "lib32", "lib64", "lib", "sbin" };
+ const char * const usrmerged_dirs[] = { };
g_autoptr(GPtrArray) args = g_ptr_array_new_with_free_func (g_free);
g_autofree char* arg_input_fd = NULL;
char validate_icon[PATH_MAX + 1];
@@ -276,8 +276,7 @@ rerun_in_sandbox (int input_fd)
"--unshare-ipc",
"--unshare-net",
"--unshare-pid",
- "--ro-bind", "/usr", "/usr",
- "--ro-bind-try", "/etc/ld.so.cache", "/etc/ld.so.cache",
+ "--ro-bind", "@storeDir@", "@storeDir@",
"--ro-bind", validate_icon, validate_icon,
NULL);

@@ -320,6 +319,9 @@ rerun_in_sandbox (int input_fd)
if (g_getenv ("G_MESSAGES_PREFIXED"))
add_args (args, "--setenv", "G_MESSAGES_PREFIXED", g_getenv ("G_MESSAGES_PREFIXED"), NULL);

+ if (g_getenv ("GDK_PIXBUF_MODULE_FILE"))
+ add_args (args, "--setenv", "GDK_PIXBUF_MODULE_FILE", g_getenv ("GDK_PIXBUF_MODULE_FILE"), NULL);
+
arg_input_fd = g_strdup_printf ("%d", input_fd);
add_args (args,
validate_icon,
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/meson.build b/meson.build
index b25f9ef..7975f85 100644
index 26da8a4..d4f95ec 100644
--- a/meson.build
+++ b/meson.build
@@ -40,8 +40,8 @@ if dataroot_dir == ''
@@ -43,8 +43,8 @@ if dataroot_dir == ''
dataroot_dir = datadir
endif

Expand All @@ -14,10 +14,10 @@ index b25f9ef..7975f85 100644

summary({
diff --git a/meson_options.txt b/meson_options.txt
index fccada3..ca87600 100644
index 64d9bd3..34675f6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -38,6 +38,10 @@ option('installed-tests',
@@ -42,6 +42,10 @@ option('installed-tests',
type: 'boolean',
value: false,
description: 'Enable installation of some test cases')
Expand All @@ -27,4 +27,4 @@ index fccada3..ca87600 100644
+ description: 'Prefix for installed tests')
option('pytest',
type: 'feature',
value: 'auto',
value: 'enabled',

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/src/portal-impl.c b/src/portal-impl.c
index 85b3a23..6d43636 100644
--- a/src/portal-impl.c
+++ b/src/portal-impl.c
@@ -275,6 +275,8 @@ load_installed_portals (gboolean opt_verbose)
diff --git a/src/xdp-portal-impl.c b/src/xdp-portal-impl.c
index 770c265..a34ca8e 100644
--- a/src/xdp-portal-impl.c
+++ b/src/xdp-portal-impl.c
@@ -277,6 +277,8 @@ load_installed_portals (gboolean opt_verbose)

/* We need to override this in the tests */
portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR");
Expand Down
16 changes: 8 additions & 8 deletions pkgs/development/libraries/xdg-desktop-portal/trash-test.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
diff --git a/tests/test_trash.py b/tests/test_trash.py
index d745cd2..173e3e5 100644
index 2637256..e89d45c 100644
--- a/tests/test_trash.py
+++ b/tests/test_trash.py
@@ -24,13 +24,6 @@ class TestTrash:
def test_version(self, portal_mock):
portal_mock.check_version(1)
@@ -13,13 +13,6 @@ class TestTrash:
def test_version(self, portals, dbus_con):
xdp.check_version(dbus_con, "Trash", 1)

- def test_trash_file_fails(self, portal_mock):
- trash_intf = portal_mock.get_dbus_interface()
- def test_trash_file_fails(self, portals, dbus_con):
- trash_intf = xdp.get_portal_iface(dbus_con, "Trash")
- with open("/proc/cmdline") as fd:
- result = trash_intf.TrashFile(fd.fileno())
-
- assert result == 0
-
def test_trash_file(self, portal_mock):
trash_intf = portal_mock.get_dbus_interface()
def test_trash_file(self, portals, dbus_con):
trash_intf = xdp.get_portal_iface(dbus_con, "Trash")