From 9121a522fdc31fb108e1e98ab66688eccc74cb53 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 23 Sep 2022 03:26:17 +0200 Subject: [PATCH] xdg-desktop-portal: fix icon validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Validation requires bubblewrap, but the current build system does not enforce it being present. Additionally, the validation itself needs to have thumbnailer Nix store paths available in sandbox. Let’s add a patch from Flatpak and introduce a test verifying it still works. This was probably broken since https://github.com/NixOS/nixpkgs/commit/c3b07a052fadf19bfa6b7a26e1c12125da4ef71d --- .../libraries/xdg-desktop-portal/default.nix | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/xdg-desktop-portal/default.nix b/pkgs/development/libraries/xdg-desktop-portal/default.nix index 05b0f5534481..438940f3bac6 100644 --- a/pkgs/development/libraries/xdg-desktop-portal/default.nix +++ b/pkgs/development/libraries/xdg-desktop-portal/default.nix @@ -3,9 +3,9 @@ , autoreconfHook , dbus , fetchFromGitHub -, fetchpatch , flatpak , fuse3 +, bubblewrap , systemdMinimal , geoclue2 , glib @@ -20,12 +20,12 @@ , python3 , pkg-config , stdenv -, substituteAll +, runCommand , wrapGAppsHook , enableGeoLocation ? true }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "xdg-desktop-portal"; version = "1.15.0"; @@ -33,11 +33,21 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "flatpak"; - repo = pname; - rev = version; + repo = "xdg-desktop-portal"; + rev = finalAttrs.version; sha256 = "sha256-Kw3zJeGwPfw1fDo8HsgYmrpgCk/PUvWZPRloKJNAJVc="; }; + 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" + '') + ]; + nativeBuildInputs = [ autoreconfHook libxml2 @@ -50,6 +60,7 @@ stdenv.mkDerivation rec { dbus flatpak fuse3 + bubblewrap systemdMinimal # libsystemd glib gsettings-desktop-schemas @@ -83,6 +94,11 @@ stdenv.mkDerivation rec { 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" + ''; }; }; @@ -92,4 +108,4 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ jtojnar ]; platforms = platforms.linux; }; -} +})