anchor.diff:  
     meta = with stdenv.lib; {
       description = "Linux application sandboxing and distribution framework";
  -    homepage = https://flatpak.org/;
  +    homepage = "https://flatpak.org/";
       license = licenses.lgpl21;
       maintainers = with maintainers; [ jtojnar ];
       platforms = platforms.linux;
  
positive.code:   ];
  
    makeFlags = [
      "installed_testdir=$(installedTests)/libexec/installed-tests/flatpak"
      "installed_test_metadir=$(installedTests)/share/installed-tests/flatpak"
    ];
  
    postPatch = ''
  
negative.code:   };
  
    patches = [
      # Hardcode paths used by tests and change test runtime generation to use files from Nix store.
      # https://github.com/flatpak/flatpak/issues/1460
      (substituteAll {
        src = ./fix-test-paths.patch;
        inherit coreutils gettext glibcLocales;
        hicolorIconTheme = hicolor-icon-theme;
      })
  
      # Hardcode paths used by Flatpak itself.
      (substituteAll {
        src = ./fix-paths.patch;
        p11 = p11-kit;
      })
  
      # Adapt paths exposed to sandbox for NixOS.
      (substituteAll {
        src = ./bubblewrap-paths.patch;
        inherit (builtins) storeDir;
      })
  
      # Allow gtk-doc to find schemas using XML_CATALOG_FILES environment variable.
      # Patch taken from gtk-doc expression.
      ./respect-xml-catalog-files-var.patch
  
      # Don’t hardcode flatpak binary path in launchers stored under user’s profile otherwise they will break after Flatpak update.
      # https://github.com/NixOS/nixpkgs/issues/43581
      ./use-flatpak-from-path.patch
  
      # Nix environment hacks should not leak into the apps.
      # https://github.com/NixOS/nixpkgs/issues/53441
      ./unset-env-vars.patch
  
      # But we want the GDK_PIXBUF_MODULE_FILE from the wrapper affect the icon validator.
      ./validate-icon-pixbuf.patch
    ];
  
    nativeBuildInputs = [
      autoreconfHook
      libxml2
      docbook_xml_dtd_412
      docbook_xml_dtd_42
      docbook_xml_dtd_43
      docbook_xsl
      which
      gobject-introspection
      gtk-doc
      intltool
      libxslt
      pkgconfig
      xmlto
      appstream-glib
      yacc
      wrapGAppsHook
    ];
  
    buildInputs = [
      bubblewrap
      bzip2
      dbus
      dconf
      glib
      gpgme
      json-glib
      libarchive
      libcap
      libseccomp
      libsoup
      lzma
      ostree
      polkit
      python3
      systemd
      xorg.libXau
      fuse
      gsettings-desktop-schemas
      glib-networking
      librsvg # for flatpak-validate-icon
    ];
  
    checkInputs = [
      valgrind
    ];
  
    # TODO: some issues with temporary files
    doCheck = false;
  
    NIX_LDFLAGS = "-lpthread";
  
  