<commit_before>{ stdenv
, lib
, ctags
, cmark
, appstream-glib
, desktop-file-utils
, fetchurl
, fetchpatch
, flatpak
, gnome
, libgit2-glib
, gi-docgen
, gobject-introspection
, glade
, gspell
, gtk3
, gtksourceview4
, json-glib
, jsonrpc-glib
, libdazzle
, libpeas
, libportal-gtk3
, libxml2
, meson
, ninja
, ostree
, pcre
, pcre2
, pkg-config
, python3
, sysprof
, template-glib
, vala
, vte
, webkitgtk
, wrapGAppsHook
, dbus
, xvfb-run
}:

stdenv.mkDerivation rec {
  pname = "gnome-builder";
  version = "41.3";

  outputs = [ "out" "devdoc" ];

  src = fetchurl {
    url = "mirror://gnome/sources/${pname}/${lib.versions.major version}/${pname}-${version}.tar.xz";
    sha256 = "4iUPyOnp8gAsRS5ZUNgmhXNNPESAs1Fnq1CKyHAlCeE=";
  };

  patches = [
    # Fix build with latest libportal
    # https://gitlab.gnome.org/GNOME/gnome-builder/-/merge_requests/486
    (fetchpatch {
      url = "https://gitlab.gnome.org/GNOME/gnome-builder/-/commit/b3bfa0df53a3749c3b73cb6c4bad5cab3fa549a1.patch";
      sha256 = "B/uCcYavFvOAPhLHZ4MRNENDd6VytILiGYwDZRUSxTE=";
    })
  ];

  nativeBuildInputs = [
    appstream-glib
    desktop-file-utils
    gi-docgen
    gobject-introspection
    meson
    ninja
    pkg-config
    python3
    python3.pkgs.wrapPython
    wrapGAppsHook
  ];

  buildInputs = [
    ctags
    cmark
    flatpak
    gnome.devhelp
    glade
    libgit2-glib
    libpeas
    libportal-gtk3
    vte
    gspell
    gtk3
    gtksourceview4
    json-glib
    jsonrpc-glib
    libdazzle
    libxml2
    ostree
    pcre
    pcre2
    python3
    sysprof
    template-glib
    vala
    webkitgtk
  ];

  checkInputs = [
    dbus
    xvfb-run
  ];

  prePatch = ''
    patchShebangs build-aux/meson/post_install.py
  '';

  mesonFlags = [
    "-Ddocs=true"

    # Making the build system correctly detect clang header and library paths
    # is difficult. Somebody should look into fixing this.
    "-Dplugin_clang=false"

    # Do not try to check if appstream images exist
    "-Dnetwork_tests=false"
  ];

  # Some tests fail due to being unable to find the Vte typelib, and I don't
  # understand why. Somebody should look into fixing this.
  doCheck = true;

  checkPhase = ''
    export NO_AT_BRIDGE=1
    xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
      meson test --print-errorlogs
  '';

  pythonPath = with python3.pkgs; requiredPythonModules [ pygobject3 ];

  preFixup = ''
    buildPythonPath "$out $pythonPath"
    gappsWrapperArgs+=(
      --prefix PYTHONPATH : "$program_PYTHONPATH"
    )

    # Ensure that all plugins get their interpreter paths fixed up.<commit_msg>gnome-builder: 41.3 → 42.alpha1<commit_after>{ stdenv
, lib
, ctags
, cmark
, appstream-glib
, desktop-file-utils
, fetchpatch
, fetchurl
, flatpak
, gnome
, libgit2-glib
, gi-docgen
, gobject-introspection
, glade
, gspell
, gtk3
, gtksourceview4
, json-glib
, jsonrpc-glib
, libdazzle
, libpeas
, libportal-gtk3
, libxml2
, meson
, ninja
, ostree
, pcre
, pcre2
, pkg-config
, python3
, sysprof
, template-glib
, vala
, vte
, webkitgtk
, wrapGAppsHook
, dbus
, xvfb-run
}:

stdenv.mkDerivation rec {
  pname = "gnome-builder";
  version = "42.alpha1";

  outputs = [ "out" "devdoc" ];

  src = fetchurl {
    url = "mirror://gnome/sources/${pname}/${lib.versions.major version}/${pname}-${version}.tar.xz";
    sha256 = "AtJ+Op2ChWWgcREWFb3zqyp1CzBb/469BwJXK3DuWnc=";
  };

  patches = [
    # Fix building docs
    # https://gitlab.gnome.org/GNOME/gnome-builder/-/merge_requests/530
    (fetchpatch {
      url = "https://gitlab.gnome.org/GNOME/gnome-builder/-/commit/e2b369ec056ff43701803c5e5185fa2ac391d238.patch";
      sha256 = "OI2CMtA0M9u6/5xmWm4i+bXOKDXmtYprCONNCU2aOj0=";
    })
  ];

  nativeBuildInputs = [
    appstream-glib
    desktop-file-utils
    gi-docgen
    gobject-introspection
    meson
    ninja
    pkg-config
    python3
    python3.pkgs.wrapPython
    wrapGAppsHook
  ];

  buildInputs = [
    ctags
    cmark
    flatpak
    gnome.devhelp
    glade
    libgit2-glib
    libpeas
    libportal-gtk3
    vte
    gspell
    gtk3
    gtksourceview4
    json-glib
    jsonrpc-glib
    libdazzle
    libxml2
    ostree
    pcre
    pcre2
    python3
    sysprof
    template-glib
    vala
    webkitgtk
  ];

  checkInputs = [
    dbus
    xvfb-run
  ];

  mesonFlags = [
    "-Ddocs=true"

    # Making the build system correctly detect clang header and library paths
    # is difficult. Somebody should look into fixing this.
    "-Dplugin_clang=false"

    # Do not try to check if appstream images exist
    "-Dnetwork_tests=false"
  ];

  # Some tests fail due to being unable to find the Vte typelib, and I don't
  # understand why. Somebody should look into fixing this.
  doCheck = true;

  postPatch = ''
    patchShebangs build-aux/meson/post_install.py
  '';

  checkPhase = ''
    export NO_AT_BRIDGE=1
    xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
      meson test --print-errorlogs
  '';

  pythonPath = with python3.pkgs; requiredPythonModules [ pygobject3 ];

  preFixup = ''
    buildPythonPath "$out $pythonPath"
    gappsWrapperArgs+=(
      --prefix PYTHONPATH : "$program_PYTHONPATH"
    )

    # Ensure that all plugins get their interpreter paths fixed up.
{'fraction_non_alphanumeric': 0.1062874251497006, 'fraction_numerical': 0.029191616766467067, 'mean_word_length': 2.7693935119887163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5319835', 'n_tokens_mistral': 2175, 'n_tokens_neox': 2046, 'n_words': 404}