nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 304 lines 8.3 kB view raw
1{ 2 lib, 3 stdenv, 4 pkgsCross, 5 appstream, 6 bison, 7 bubblewrap, 8 buildPackages, 9 bzip2, 10 coreutils, 11 curl, 12 dconf, 13 desktop-file-utils, 14 docbook-xsl-nons, 15 docbook_xml_dtd_45, 16 fetchurl, 17 fuse3, 18 gdk-pixbuf, 19 gettext, 20 glib, 21 glib-networking, 22 gobject-introspection, 23 gpgme, 24 gsettings-desktop-schemas, 25 gtk-doc, 26 gtk3, 27 hicolor-icon-theme, 28 json-glib, 29 libarchive, 30 libcap, 31 librsvg, 32 libseccomp, 33 libxml2, 34 libxslt, 35 malcontent, 36 meson, 37 ninja, 38 nix-update-script, 39 nixos-icons, 40 ostree, 41 p11-kit, 42 pkg-config, 43 polkit, 44 python3, 45 runCommand, 46 shared-mime-info, 47 socat, 48 replaceVars, 49 systemd, 50 testers, 51 valgrind, 52 validatePkgConfig, 53 wayland, 54 wayland-protocols, 55 wayland-scanner, 56 wrapGAppsNoGuiHook, 57 xdg-dbus-proxy, 58 xmlto, 59 libxau, 60 zstd, 61 withAutoSideloading ? false, 62 withDconf ? lib.meta.availableOn stdenv.hostPlatform dconf, 63 withDocbookDocs ? true, 64 withGlibNetworking ? lib.meta.availableOn stdenv.hostPlatform glib-networking, 65 withGtkDoc ? 66 withDocbookDocs 67 && stdenv.buildPlatform.canExecute stdenv.hostPlatform 68 # https://github.com/mesonbuild/meson/pull/14257 69 && !stdenv.hostPlatform.isStatic, 70 withIntrospection ? 71 lib.meta.availableOn stdenv.hostPlatform gobject-introspection 72 && stdenv.hostPlatform.emulatorAvailable buildPackages, 73 withMalcontent ? lib.meta.availableOn stdenv.hostPlatform malcontent, 74 withMan ? withDocbookDocs, 75 withP11Kit ? lib.meta.availableOn stdenv.hostPlatform p11-kit, 76 withPolkit ? lib.meta.availableOn stdenv.hostPlatform polkit, 77 withSELinuxModule ? false, 78 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, 79}: 80 81stdenv.mkDerivation (finalAttrs: { 82 pname = "flatpak"; 83 version = "1.16.2"; 84 85 # TODO: split out lib once we figure out what to do with triggerdir 86 outputs = [ 87 "out" 88 "dev" 89 ] 90 ++ lib.optionals withDocbookDocs [ 91 "doc" 92 ] 93 ++ lib.optionals withGtkDoc [ 94 "devdoc" 95 ] 96 ++ lib.optional finalAttrs.doCheck "installedTests" 97 ++ lib.optional withMan "man"; 98 99 src = fetchurl { 100 url = "https://github.com/flatpak/flatpak/releases/download/${finalAttrs.version}/flatpak-${finalAttrs.version}.tar.xz"; 101 hash = "sha256-aRctGw2Fxo+B5t3wEV+OGwXXOxsBD+qNnssDvIrYQ+s="; 102 }; 103 104 patches = [ 105 # Use flatpak from PATH to avoid references to `/nix/store` in `/desktop` files. 106 # Applications containing `DBusActivatable` entries should be able to find the flatpak binary. 107 # https://github.com/NixOS/nixpkgs/issues/138956 108 ./binary-path.patch 109 110 # Try mounting fonts and icons from NixOS locations if FHS locations don't exist. 111 # https://github.com/NixOS/nixpkgs/issues/119433 112 ./fix-fonts-icons.patch 113 114 # Nix environment hacks should not leak into the apps. 115 # https://github.com/NixOS/nixpkgs/issues/53441 116 ./unset-env-vars.patch 117 118 # The icon validator needs to access the gdk-pixbuf loaders in the Nix store 119 # and cannot bind FHS paths since those are not available on NixOS. 120 finalAttrs.passthru.icon-validator-patch 121 ] 122 ++ lib.optionals finalAttrs.doCheck [ 123 # Hardcode paths used by tests and change test runtime generation to use files from Nix store. 124 # https://github.com/flatpak/flatpak/issues/1460 125 (replaceVars ./fix-test-paths.patch { 126 inherit 127 coreutils 128 gettext 129 gtk3 130 socat 131 ; 132 dfu = desktop-file-utils; 133 hicolorIconTheme = hicolor-icon-theme; 134 smi = shared-mime-info; 135 }) 136 ] 137 ++ lib.optionals withP11Kit [ 138 # Hardcode p11-kit path used by Flatpak itself. 139 # If disabled, will have to be on PATH. 140 (replaceVars ./fix-paths.patch { 141 p11kit = lib.getExe p11-kit; 142 }) 143 ]; 144 145 # Fixup shebangs in some scripts 146 # 147 # Don't prefix the already absolute `man` directory with the install prefix 148 postPatch = '' 149 patchShebangs buildutil/ tests/ 150 patchShebangs --build subprojects/variant-schema-compiler/variant-schema-compiler 151 152 substituteInPlace doc/meson.build \ 153 --replace-fail '$MESON_INSTALL_DESTDIR_PREFIX/@1@/@2@' '@1@/@2@' 154 155 substituteInPlace triggers/gtk-icon-cache.trigger \ 156 --replace-fail '/usr/share/icons/hicolor/index.theme' '/run/current-system/sw/share/icons/hicolor/index.theme' 157 ''; 158 159 # Fixup PATHs in trigger scripts 160 postInstall = '' 161 wrapProgram $out/share/flatpak/triggers/desktop-database.trigger --prefix PATH : ${ 162 lib.makeBinPath [ 163 desktop-file-utils 164 ] 165 } 166 167 wrapProgram $out/share/flatpak/triggers/gtk-icon-cache.trigger --prefix PATH : ${ 168 lib.makeBinPath [ 169 coreutils 170 gtk3 171 ] 172 } 173 174 wrapProgram $out/share/flatpak/triggers/mime-database.trigger --prefix PATH : ${ 175 lib.makeBinPath [ 176 shared-mime-info 177 ] 178 } 179 ''; 180 181 strictDeps = true; 182 183 depsBuildBuild = [ pkg-config ]; 184 185 nativeBuildInputs = [ 186 (python3.pythonOnBuildForHost.withPackages (p: [ p.pyparsing ])) 187 bison 188 glib 189 meson 190 ninja 191 pkg-config 192 validatePkgConfig 193 wayland-scanner 194 wrapGAppsNoGuiHook 195 ] 196 ++ lib.optional withGtkDoc gtk-doc 197 ++ lib.optional withIntrospection gobject-introspection 198 ++ lib.optional withMan libxslt 199 ++ lib.optional withSELinuxModule bzip2 200 ++ lib.optionals withDocbookDocs [ 201 docbook-xsl-nons 202 docbook_xml_dtd_45 203 xmlto 204 ]; 205 206 buildInputs = [ 207 appstream 208 curl 209 fuse3 210 gdk-pixbuf 211 gpgme 212 gsettings-desktop-schemas 213 json-glib 214 libarchive 215 libcap 216 librsvg # for flatpak-validate-icon 217 libseccomp 218 libxml2 219 python3 220 wayland 221 wayland-protocols 222 libxau 223 zstd 224 ] 225 ++ lib.optional withDconf dconf 226 ++ lib.optional withGlibNetworking glib-networking 227 ++ lib.optional withMalcontent malcontent 228 ++ lib.optional withPolkit polkit 229 ++ lib.optional withSystemd systemd; 230 231 # Required by flatpak.pc 232 propagatedBuildInputs = [ 233 glib 234 ostree 235 ]; 236 237 mesonFlags = [ 238 (lib.mesonBool "auto_sideloading" withAutoSideloading) 239 (lib.mesonBool "installed_tests" finalAttrs.finalPackage.doCheck) 240 (lib.mesonBool "tests" finalAttrs.finalPackage.doCheck) 241 (lib.mesonEnable "dconf" withDconf) 242 (lib.mesonEnable "docbook_docs" withDocbookDocs) 243 (lib.mesonEnable "gir" withIntrospection) 244 (lib.mesonEnable "gtkdoc" withGtkDoc) 245 (lib.mesonEnable "malcontent" withMalcontent) 246 (lib.mesonEnable "man" withMan) 247 (lib.mesonEnable "selinux_module" withSELinuxModule) 248 (lib.mesonEnable "system_helper" withPolkit) 249 (lib.mesonEnable "systemd" withSystemd) 250 (lib.mesonOption "dbus_config_dir" (placeholder "out" + "/share/dbus-1/system.d")) 251 (lib.mesonOption "profile_dir" (placeholder "out" + "/etc/profile.d")) 252 (lib.mesonOption "system_bubblewrap" (lib.getExe bubblewrap)) 253 (lib.mesonOption "system_dbus_proxy" (lib.getExe xdg-dbus-proxy)) 254 (lib.mesonOption "system_fusermount" "/run/wrappers/bin/fusermount3") 255 (lib.mesonOption "system_install_dir" "/var/lib/flatpak") 256 (lib.mesonOption "sysconfdir" "/etc") 257 ]; 258 259 nativeCheckInputs = [ 260 polkit 261 socat 262 valgrind 263 ]; 264 265 # TODO: Many issues with temporary files, FHS environments, timeouts, and our current patches 266 doCheck = false; 267 268 separateDebugInfo = true; 269 270 passthru = { 271 icon-validator-patch = replaceVars ./fix-icon-validation.patch { 272 inherit (builtins) storeDir; 273 }; 274 275 tests = { 276 cross-aarch64 = pkgsCross.aarch64-multiplatform.flatpak; 277 278 pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; }; 279 280 validate-icon = runCommand "test-icon-validation" { } '' 281 ${finalAttrs.finalPackage}/libexec/flatpak-validate-icon \ 282 --sandbox 512 512 \ 283 "${nixos-icons}/share/icons/hicolor/512x512/apps/nix-snowflake.png" > "$out" 284 285 grep format=png "$out" 286 ''; 287 288 version = testers.testVersion { package = finalAttrs.finalPackage; }; 289 }; 290 291 updateScript = nix-update-script { }; 292 }; 293 294 meta = { 295 description = "Linux application sandboxing and distribution framework"; 296 homepage = "https://flatpak.org/"; 297 changelog = "https://github.com/flatpak/flatpak/releases/tag/${finalAttrs.version}"; 298 license = lib.licenses.lgpl21Plus; 299 maintainers = with lib.maintainers; [ getchoo ]; 300 mainProgram = "flatpak"; 301 platforms = lib.platforms.linux; 302 pkgConfigModules = [ "flatpak" ]; 303 }; 304})