nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 195 lines 5.0 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 flatpak, 5 fuse3, 6 bubblewrap, 7 docutils, 8 systemdMinimal, 9 geoclue2, 10 glib, 11 gsettings-desktop-schemas, 12 json-glib, 13 meson, 14 ninja, 15 nixosTests, 16 pipewire, 17 gdk-pixbuf, 18 librsvg, 19 gobject-introspection, 20 python3, 21 pkg-config, 22 stdenv, 23 runCommand, 24 wrapGAppsNoGuiHook, 25 bash, 26 dbus, 27 gst_all_1, 28 libgudev, 29 umockdev, 30 replaceVars, 31 enableGeoLocation ? true, 32 enableSystemd ? true, 33}: 34 35stdenv.mkDerivation (finalAttrs: { 36 pname = "xdg-desktop-portal"; 37 version = "1.20.3"; 38 39 outputs = [ 40 "out" 41 "installedTests" 42 ]; 43 separateDebugInfo = true; 44 45 src = fetchFromGitHub { 46 owner = "flatpak"; 47 repo = "xdg-desktop-portal"; 48 tag = finalAttrs.version; 49 hash = "sha256-ntTGEsk8GlXkp3i9RtF+T7jqnNdL2GVbu05d68WVTYc="; 50 }; 51 52 patches = [ 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 (replaceVars ./fix-icon-validation.patch { 56 inherit (builtins) storeDir; 57 }) 58 59 # Same for the sound validator, except the gdk-pixbuf part. 60 (replaceVars ./fix-sound-validation.patch { 61 inherit (builtins) storeDir; 62 }) 63 64 # Allow installing installed tests to a separate output. 65 ./installed-tests-path.patch 66 67 # Look for portal definitions under path from `NIX_XDG_DESKTOP_PORTAL_DIR` environment variable. 68 # While upstream has `XDG_DESKTOP_PORTAL_DIR`, it is meant for tests and actually blocks 69 # any configs from being loaded from anywhere else. 70 ./nix-pkgdatadir-env.patch 71 72 # test tries to read /proc/cmdline, which is not intended to be accessible in the sandbox 73 ./trash-test.patch 74 ]; 75 76 nativeBuildInputs = [ 77 docutils # for rst2man 78 glib 79 meson 80 ninja 81 pkg-config 82 wrapGAppsNoGuiHook 83 ]; 84 85 buildInputs = [ 86 flatpak 87 fuse3 88 bubblewrap 89 glib 90 gsettings-desktop-schemas 91 json-glib 92 pipewire 93 gst_all_1.gst-plugins-base 94 libgudev 95 96 # For icon validator 97 gdk-pixbuf 98 librsvg 99 bash 100 ] 101 ++ lib.optionals enableGeoLocation [ 102 geoclue2 103 ] 104 ++ lib.optionals enableSystemd [ 105 systemdMinimal # libsystemd 106 ]; 107 108 nativeCheckInputs = [ 109 dbus 110 gdk-pixbuf 111 gst_all_1.gstreamer 112 gst_all_1.gst-plugins-good 113 gobject-introspection 114 115 # NB: this Python is used both for build-time tests 116 # and for installed (VM) tests, so it includes dependencies 117 # for both 118 (python3.withPackages (ps: [ 119 ps.pytest 120 ps.python-dbusmock 121 ps.pygobject3 122 ps.dbus-python 123 ])) 124 umockdev 125 ]; 126 127 checkInputs = [ umockdev ]; 128 129 mesonFlags = [ 130 "--sysconfdir=/etc" 131 "-Dinstalled-tests=true" 132 "-Dinstalled_test_prefix=${placeholder "installedTests"}" 133 "-Ddocumentation=disabled" # pulls in a whole lot of extra stuff 134 (lib.mesonEnable "systemd" enableSystemd) 135 ] 136 ++ lib.optionals (!enableGeoLocation) [ 137 "-Dgeoclue=disabled" 138 ] 139 ++ lib.optionals (!finalAttrs.finalPackage.doCheck) [ 140 "-Dtests=disabled" 141 ]; 142 143 strictDeps = true; 144 145 doCheck = true; 146 147 postPatch = '' 148 # until/unless bubblewrap ships a pkg-config file, meson has no way to find it when cross-compiling. 149 substituteInPlace meson.build \ 150 --replace-fail "find_program('bwrap'" "find_program('${lib.getExe bubblewrap}'" 151 152 patchShebangs src/generate-method-info.py 153 patchShebangs tests/run-test.sh 154 ''; 155 156 preCheck = lib.optionalString finalAttrs.finalPackage.doCheck '' 157 # For test_trash_file 158 export HOME=$(mktemp -d) 159 160 # Upstream disables a few tests in CI upstream as they are known to 161 # be flaky. Let's disable those downstream as hydra exhibits similar 162 # flakes: 163 # https://github.com/NixOS/nixpkgs/pull/270085#issuecomment-1840053951 164 export XDP_TEST_IN_CI=1 165 166 # need to set this ourselves, because the tests will set LD_PRELOAD=libumockdev-preload.so, 167 # which can't be found because it's not in default rpath 168 export LD_PRELOAD=${lib.getLib umockdev}/lib/libumockdev-preload.so 169 ''; 170 171 # We can't disable the installedTests output when doCheck is disabled, 172 # because that produces an infinite recursion. 173 preFixup = lib.optionalString (!finalAttrs.finalPackage.doCheck) '' 174 mkdir $installedTests 175 ''; 176 177 passthru = { 178 tests = { 179 installedTests = nixosTests.installed-tests.xdg-desktop-portal; 180 181 validate-icon = runCommand "test-icon-validation" { } '' 182 ${finalAttrs.finalPackage}/libexec/xdg-desktop-portal-validate-icon --ruleset=desktop --sandbox --path=${../../../applications/audio/zynaddsubfx/ZynLogo.svg} > "$out" 183 grep format=svg "$out" 184 ''; 185 }; 186 }; 187 188 meta = { 189 description = "Desktop integration portals for sandboxed apps"; 190 homepage = "https://flatpak.github.io/xdg-desktop-portal"; 191 license = lib.licenses.lgpl2Plus; 192 maintainers = with lib.maintainers; [ jtojnar ]; 193 platforms = lib.platforms.linux; 194 }; 195})