{
  lib,
  stdenv,
  fetchpatch,
  fetchurl,
  meson,
  ninja,
  pkg-config,
  gettext,
  libxml2,
  gobject-introspection,
  gnome,
  glib,
}:

stdenv.mkDerivation rec {
  pname = "totem-pl-parser";
  version = "3.26.7";

  src = fetchurl {
    url = "mirror://gnome/sources/totem-pl-parser/${lib.versions.majorMinor version}/totem-pl-parser-${version}.tar.xz";
    sha256 = "YNUXwayr5UrjN/ZEUSZPx2cwaW6q4mtUgPs3FmaJtfM=";
  };

  patches = [
    # Upstream MR: https://gitlab.gnome.org/GNOME/totem-pl-parser/-/merge_requests/46
    (fetchpatch {
      url = "https://gitlab.gnome.org/GNOME/totem-pl-parser/-/commit/f4f69c9b99095416aaed18a73f7486ad9eb04aa9.patch";
      sha256 = "sha256-Uya5fgFgauv5rIpVK3CDGCieyMus7VjcLMMe/vQ2WWY=";
    })
  ];

  passthru = {
    updateScript = gnome.updateScript {
      packageName = pname;
      versionPolicy = "odd-unstable";
    };
  };

  strictDeps = true;
  depsBuildBuild = [ pkg-config ];
  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    gettext
    glib
    gobject-introspection
  ];
  buildInputs = [
    libxml2
    glib
  ];

  mesonFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
    "-Dintrospection=false"
  ];

  meta = {
    homepage = "https://gitlab.gnome.org/GNOME/totem-pl-parser";
    description = "Simple GObject-based library to parse and save a host of playlist formats";
    teams = [ lib.teams.gnome ];
    license = lib.licenses.lgpl2;
    platforms = lib.platforms.unix;
  };
}
