Skip to content

Commit 7b73ac5

Browse files
authored
[staging-next] xdg-desktop-portal: 1.18.4 -> 1.20.0 (#387894)
2 parents 22448be + 98b086d commit 7b73ac5

File tree

8 files changed

+164
-117
lines changed

8 files changed

+164
-117
lines changed
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
{ pkgs, makeInstalledTest, ... }:
1+
{
2+
lib,
3+
pkgs,
4+
makeInstalledTest,
5+
...
6+
}:
27

38
makeInstalledTest {
49
tested = pkgs.xdg-desktop-portal;
510

6-
# Red herring
7-
# Failed to load RealtimeKit property: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.RealtimeKit1 was not provided by any .service files
8-
# Maybe a red herring, enabling PipeWire doesn't fix the location test.
9-
# Failed connect to PipeWire: Couldn't connect to PipeWire
1011
testConfig = {
1112
environment.variables = {
12-
TEST_IN_CI = 1;
13-
XDG_DATA_DIRS = "${pkgs.xdg-desktop-portal.installedTests}/share/installed-tests/xdg-desktop-portal/share";
13+
GI_TYPELIB_PATH = lib.makeSearchPath "lib/girepository-1.0" [
14+
pkgs.glib.out
15+
pkgs.umockdev.out
16+
];
17+
# need to set this ourselves, because the tests will set LD_PRELOAD=libumockdev-preload.so,
18+
# which can't be found because it's not in default rpath
19+
LD_PRELOAD = "${pkgs.umockdev.out}/lib/libumockdev-preload.so";
20+
XDP_TEST_IN_CI = 1;
1421
};
15-
# Broken, see comment in the package file.
16-
#services.geoclue2 = {
17-
# enable = true;
18-
# enableDemoAgent = true;
19-
#};
20-
#location.provider = "geoclue2";
22+
environment.systemPackages = with pkgs; [
23+
umockdev
24+
wireless-regdb
25+
];
26+
services.geoclue2 = {
27+
enable = true;
28+
enableDemoAgent = true;
29+
};
30+
location.provider = "geoclue2";
2131
};
2232
}

pkgs/development/libraries/xdg-desktop-portal/default.nix

Lines changed: 53 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
flatpak,
55
fuse3,
66
bubblewrap,
7-
docbook_xml_dtd_412,
8-
docbook_xml_dtd_43,
9-
docbook_xsl,
107
docutils,
118
systemdMinimal,
129
geoclue2,
1310
glib,
1411
gsettings-desktop-schemas,
1512
json-glib,
16-
libportal,
17-
libxml2,
1813
meson,
1914
ninja,
2015
nixosTests,
@@ -26,16 +21,20 @@
2621
pkg-config,
2722
stdenv,
2823
runCommand,
29-
wrapGAppsHook3,
30-
xmlto,
24+
wrapGAppsNoGuiHook,
3125
bash,
26+
dbus,
27+
gst_all_1,
28+
libgudev,
29+
umockdev,
30+
substituteAll,
3231
enableGeoLocation ? true,
3332
enableSystemd ? true,
3433
}:
3534

3635
stdenv.mkDerivation (finalAttrs: {
3736
pname = "xdg-desktop-portal";
38-
version = "1.18.4";
37+
version = "1.20.0";
3938

4039
outputs = [
4140
"out"
@@ -45,18 +44,23 @@ stdenv.mkDerivation (finalAttrs: {
4544
src = fetchFromGitHub {
4645
owner = "flatpak";
4746
repo = "xdg-desktop-portal";
48-
rev = finalAttrs.version;
49-
hash = "sha256-o+aO7uGewDPrtgOgmp/CE2uiqiBLyo07pVCFrtlORFQ=";
47+
tag = finalAttrs.version;
48+
hash = "sha256-FHMa8fTr8qNEM5WptuMjMs/XOsvmFxi8pDaCrwJ3/ww=";
5049
};
5150

5251
patches = [
5352
# The icon validator copied from Flatpak needs to access the gdk-pixbuf loaders
5453
# 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"
59-
'')
54+
(substituteAll {
55+
src = ./fix-icon-validation.patch;
56+
inherit (builtins) storeDir;
57+
})
58+
59+
# Same for the sound validator, except the gdk-pixbuf part.
60+
(substituteAll {
61+
src = ./fix-sound-validation.patch;
62+
inherit (builtins) storeDir;
63+
})
6064

6165
# Allow installing installed tests to a separate output.
6266
./installed-tests-path.patch
@@ -68,23 +72,14 @@ stdenv.mkDerivation (finalAttrs: {
6872

6973
# test tries to read /proc/cmdline, which is not intended to be accessible in the sandbox
7074
./trash-test.patch
71-
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
7575
];
7676

7777
nativeBuildInputs = [
78-
docbook_xml_dtd_412
79-
docbook_xml_dtd_43
80-
docbook_xsl
8178
docutils # for rst2man
82-
libxml2
8379
meson
8480
ninja
8581
pkg-config
86-
wrapGAppsHook3
87-
xmlto
82+
wrapGAppsNoGuiHook
8883
];
8984

9085
buildInputs =
@@ -95,19 +90,14 @@ stdenv.mkDerivation (finalAttrs: {
9590
glib
9691
gsettings-desktop-schemas
9792
json-glib
98-
libportal
9993
pipewire
94+
gst_all_1.gst-plugins-base
95+
libgudev
96+
umockdev
10097

10198
# For icon validator
10299
gdk-pixbuf
103100
librsvg
104-
105-
# For document-fuse installed test.
106-
(python3.withPackages (
107-
pp: with pp; [
108-
pygobject3
109-
]
110-
))
111101
bash
112102
]
113103
++ lib.optionals enableGeoLocation [
@@ -118,25 +108,37 @@ stdenv.mkDerivation (finalAttrs: {
118108
];
119109

120110
nativeCheckInputs = [
111+
dbus
112+
gdk-pixbuf
113+
gst_all_1.gstreamer
114+
gst_all_1.gst-plugins-good
121115
gobject-introspection
122-
python3.pkgs.pytest
123-
python3.pkgs.python-dbusmock
124-
python3.pkgs.pygobject3
125-
python3.pkgs.dbus-python
116+
117+
# NB: this Python is used both for build-time tests
118+
# and for installed (VM) tests, so it includes dependencies
119+
# for both
120+
(python3.withPackages (ps: [
121+
ps.pytest
122+
ps.python-dbusmock
123+
ps.pygobject3
124+
ps.dbus-python
125+
]))
126+
umockdev
126127
];
127128

128129
mesonFlags =
129130
[
130131
"--sysconfdir=/etc"
131132
"-Dinstalled-tests=true"
132133
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
134+
"-Ddocumentation=disabled" # pulls in a whole lot of extra stuff
133135
(lib.mesonEnable "systemd" enableSystemd)
134136
]
135137
++ lib.optionals (!enableGeoLocation) [
136138
"-Dgeoclue=disabled"
137139
]
138140
++ lib.optionals (!finalAttrs.finalPackage.doCheck) [
139-
"-Dpytest=disabled"
141+
"-Dtests=disabled"
140142
];
141143

142144
strictDeps = true;
@@ -148,13 +150,8 @@ stdenv.mkDerivation (finalAttrs: {
148150
substituteInPlace meson.build \
149151
--replace-fail "find_program('bwrap'" "find_program('${lib.getExe bubblewrap}'"
150152
151-
# Disable test failing with libportal 0.9.0
152-
${
153-
assert (lib.versionOlder finalAttrs.version "1.20.0");
154-
"# TODO: Remove when updating to x-d-p 1.20.0"
155-
}
156-
substituteInPlace tests/test-portals.c \
157-
--replace-fail 'g_test_add_func ("/portal/notification/bad-arg", test_notification_bad_arg);' ""
153+
patchShebangs src/generate-method-info.py
154+
patchShebangs tests/run-test.sh
158155
'';
159156

160157
preCheck = ''
@@ -165,42 +162,29 @@ stdenv.mkDerivation (finalAttrs: {
165162
# be flaky. Let's disable those downstream as hydra exhibits similar
166163
# flakes:
167164
# https://github.com/NixOS/nixpkgs/pull/270085#issuecomment-1840053951
168-
export TEST_IN_CI=1
169-
'';
165+
export XDP_TEST_IN_CI=1
170166
171-
postFixup =
172-
let
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";
175-
176-
in
177-
''
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
185-
fi
186-
'';
167+
# need to set this ourselves, because the tests will set LD_PRELOAD=libumockdev-preload.so,
168+
# which can't be found because it's not in default rpath
169+
export LD_PRELOAD=${lib.getLib umockdev}/lib/libumockdev-preload.so
170+
'';
187171

188172
passthru = {
189173
tests = {
190174
installedTests = nixosTests.installed-tests.xdg-desktop-portal;
191175

192176
validate-icon = runCommand "test-icon-validation" { } ''
193-
${finalAttrs.finalPackage}/libexec/xdg-desktop-portal-validate-icon --sandbox 512 512 ${../../../applications/audio/zynaddsubfx/ZynLogo.svg} > "$out"
177+
${finalAttrs.finalPackage}/libexec/xdg-desktop-portal-validate-icon --ruleset=desktop --sandbox --path=${../../../applications/audio/zynaddsubfx/ZynLogo.svg} > "$out"
194178
grep format=svg "$out"
195179
'';
196180
};
197181
};
198182

199-
meta = with lib; {
183+
meta = {
200184
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;
185+
homepage = "https://flatpak.github.io/xdg-desktop-portal";
186+
license = lib.licenses.lgpl2Plus;
187+
maintainers = with lib.maintainers; [ jtojnar ];
188+
platforms = lib.platforms.linux;
205189
};
206190
})
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
diff --git a/src/validate-icon.c b/src/validate-icon.c
2+
index c42265b..320f028 100644
3+
--- a/src/validate-icon.c
4+
+++ b/src/validate-icon.c
5+
@@ -254,7 +254,7 @@ flatpak_get_bwrap (void)
6+
static int
7+
rerun_in_sandbox (int input_fd)
8+
{
9+
- const char * const usrmerged_dirs[] = { "bin", "lib32", "lib64", "lib", "sbin" };
10+
+ const char * const usrmerged_dirs[] = { };
11+
g_autoptr(GPtrArray) args = g_ptr_array_new_with_free_func (g_free);
12+
g_autofree char* arg_input_fd = NULL;
13+
char validate_icon[PATH_MAX + 1];
14+
@@ -276,8 +276,7 @@ rerun_in_sandbox (int input_fd)
15+
"--unshare-ipc",
16+
"--unshare-net",
17+
"--unshare-pid",
18+
- "--ro-bind", "/usr", "/usr",
19+
- "--ro-bind-try", "/etc/ld.so.cache", "/etc/ld.so.cache",
20+
+ "--ro-bind", "@storeDir@", "@storeDir@",
21+
"--ro-bind", validate_icon, validate_icon,
22+
NULL);
23+
24+
@@ -320,6 +319,9 @@ rerun_in_sandbox (int input_fd)
25+
if (g_getenv ("G_MESSAGES_PREFIXED"))
26+
add_args (args, "--setenv", "G_MESSAGES_PREFIXED", g_getenv ("G_MESSAGES_PREFIXED"), NULL);
27+
28+
+ if (g_getenv ("GDK_PIXBUF_MODULE_FILE"))
29+
+ add_args (args, "--setenv", "GDK_PIXBUF_MODULE_FILE", g_getenv ("GDK_PIXBUF_MODULE_FILE"), NULL);
30+
+
31+
arg_input_fd = g_strdup_printf ("%d", input_fd);
32+
add_args (args,
33+
validate_icon,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/src/validate-sound.c b/src/validate-sound.c
2+
index 7348d46..8b87c78 100644
3+
--- a/src/validate-sound.c
4+
+++ b/src/validate-sound.c
5+
@@ -234,7 +234,7 @@ flatpak_get_bwrap (void)
6+
static int
7+
rerun_in_sandbox (int input_fd)
8+
{
9+
- const char * const usrmerged_dirs[] = { "bin", "lib32", "lib64", "lib", "sbin" };
10+
+ const char * const usrmerged_dirs[] = { };
11+
int i;
12+
g_autoptr(GPtrArray) args = g_ptr_array_new_with_free_func (g_free);
13+
char validate_sound[PATH_MAX + 1];
14+
@@ -255,8 +255,7 @@ rerun_in_sandbox (int input_fd)
15+
"--unshare-ipc",
16+
"--unshare-net",
17+
"--unshare-pid",
18+
- "--ro-bind", "/usr", "/usr",
19+
- "--ro-bind-try", "/etc/ld.so.cache", "/etc/ld.so.cache",
20+
+ "--ro-bind", "@storeDir@", "@storeDir@",
21+
"--ro-bind", validate_sound, validate_sound,
22+
NULL);
23+
24+
@@ -299,6 +298,8 @@ rerun_in_sandbox (int input_fd)
25+
if (g_getenv ("G_MESSAGES_PREFIXED"))
26+
add_args (args, "--setenv", "G_MESSAGES_PREFIXED", g_getenv ("G_MESSAGES_PREFIXED"), NULL);
27+
28+
+ if (g_getenv ("GST_PLUGIN_SYSTEM_PATH_1_0"))
29+
+ add_args (args, "--setenv", "GST_PLUGIN_SYSTEM_PATH_1_0", g_getenv ("GST_PLUGIN_SYSTEM_PATH_1_0"), NULL);
30+
31+
arg_input_fd = g_strdup_printf ("%d", input_fd);
32+
add_args (args, validate_sound, "--fd", arg_input_fd, NULL);
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/meson.build b/meson.build
2-
index b25f9ef..7975f85 100644
2+
index 4238adb..d3f89fd 100644
33
--- a/meson.build
44
+++ b/meson.build
5-
@@ -40,8 +40,8 @@ if dataroot_dir == ''
5+
@@ -43,8 +43,8 @@ if dataroot_dir == ''
66
dataroot_dir = datadir
77
endif
88

@@ -14,17 +14,14 @@ index b25f9ef..7975f85 100644
1414

1515
summary({
1616
diff --git a/meson_options.txt b/meson_options.txt
17-
index fccada3..ca87600 100644
17+
index ed8c311..0a2bf7e 100644
1818
--- a/meson_options.txt
1919
+++ b/meson_options.txt
20-
@@ -38,6 +38,10 @@ option('installed-tests',
21-
type: 'boolean',
22-
value: false,
23-
description: 'Enable installation of some test cases')
20+
@@ -54,3 +54,7 @@ option('sandboxed-sound-validation',
21+
type: 'feature',
22+
value: 'enabled',
23+
description: 'Use Bubblewrap to sandbox sound validation. Disabling this option may lead to security vulnerabilities.')
2424
+option('installed_test_prefix',
25-
+ type: 'string',
26-
+ value: '',
27-
+ description: 'Prefix for installed tests')
28-
option('pytest',
29-
type: 'feature',
30-
value: 'auto',
25+
+ type: 'string',
26+
+ value: '',
27+
+ description: 'Prefix for installed tests')

pkgs/development/libraries/xdg-desktop-portal/installed-tests-share.patch

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)