<commit_before>{ stdenv, fetchurl, fetchpatch, pkgconfig, libpng, openssl, curl, gtk2, check, SDL
, libXcursor, libXrandr, makeWrapper
, libwebp
, libxml2, libidn, perl, perlPackages, xxd
, uilib ? "framebuffer"
, nsgenbind
, libnsfb
, libwapcaplet
, libparserutils
, libnslog
, libcss
, libhubbub
, libdom
, libnsbmp
, libnsgif
, libsvgtiny
, libnsutils
, libnspsl
, libutf8proc
, wrapGAppsHook
}:

stdenv.mkDerivation rec {

  name = "netsurf-${version}";
  version = "3.9";

  src = fetchurl {
    url = "http://download.netsurf-browser.org/netsurf/releases/source/netsurf-${version}-src.tar.gz";
    sha256 = "1hzcm2s2wh5sapgr000lg63hcdbj6hyajxl43xa1x80kc5piqbyp";
  };

  patches = [
    # GTK: prefer using curl's intrinsic defaults for CURLOPT_CA*
    (fetchpatch {
	  name = "0001-GTK-prefer-using-curl-s-intrinsic-defaults-for-CURLO.patch";
      url = "http://source.netsurf-browser.org/netsurf.git/patch/?id=87177d8aa109206d131e0d80a2080ce55dab01c7";
      sha256 = "08bc60pc5k5qpckqv21zgmgszj3rpwskfc84shs8vg92vkimv2ai";
    })
  ];

  nativeBuildInputs = [
    perl
    perlPackages.HTMLParser
    pkgconfig
    xxd
  ] ++ stdenv.lib.optionals (uilib == "gtk") [
    wrapGAppsHook
  ];

  buildInputs = [ libpng openssl curl gtk2 check libxml2 libidn
    libXcursor libXrandr makeWrapper SDL
    libwebp
    nsgenbind
    libnsfb
    libwapcaplet
    libparserutils
    libnslog
    libcss
    libhubbub
    libdom
    libnsbmp
    libnsgif
    libsvgtiny
    libnsutils
    libnspsl
    libutf8proc
 ];

  preConfigure = ''
    cat <<EOF > Makefile.conf
    override NETSURF_GTK_RESOURCES := $out/share/Netsurf/${uilib}/res
    override NETSURF_USE_GRESOURCE := YES
    EOF
  '';

  makeFlags = [
    "PREFIX=$(out)"
    "TARGET=${uilib}"
  ];

  installPhase = ''
    mkdir -p $out/bin $out/share/Netsurf/${uilib}
    cmd=$(case "${uilib}" in framebuffer) echo nsfb;; gtk) echo nsgtk;; esac)
    cp $cmd $out/bin/netsurf
    tar -hcf - frontends/${uilib}/res | (cd $out/share/Netsurf/ && tar -xvpf -)
  '';

  preFixup = ''
    gappsWrapperArgs+=(
      --set NETSURFRES $out/share/Netsurf/${uilib}/res
    )
  '' + stdenv.lib.optionalString (uilib != "gtk") ''
    wrapProgram $out/bin/netsurf "''${gappsWrapperArgs[@]}"
  '';

  meta = with stdenv.lib; {
    homepage = http://www.netsurf-browser.org/;
    description = "Free opensource web browser";
    license = licenses.gpl2;
    maintainers = [ maintainers.vrthra ];
    platforms = platforms.linux;
  };
}
<commit_msg>netsurf: cleanup derivation + reformat<commit_after>{ stdenv, fetchurl, fetchpatch, makeWrapper, wrapGAppsHook

# Buildtime dependencies.

, check, pkgconfig, xxd

# Runtime dependencies.

, curl, expat, libXcursor, libXrandr, libidn, libjpeg, libpng, libwebp, libxml2
, openssl, perl, perlPackages

# uilib-specific dependencies

, gtk2 # GTK 2
, SDL  # Framebuffer

# Configuration

, uilib ? "framebuffer"

# Netsurf-specific dependencies

, libcss, libdom, libhubbub, libnsbmp, libnsfb, libnsgif
, libnslog, libnspsl, libnsutils, libparserutils, libsvgtiny, libutf8proc
, libwapcaplet, nsgenbind
}:

let
  inherit (stdenv.lib) optional optionals;
in
stdenv.mkDerivation rec {

  name = "netsurf-${version}";
  version = "3.9";

  src = fetchurl {
    url = "http://download.netsurf-browser.org/netsurf/releases/source/netsurf-${version}-src.tar.gz";
    sha256 = "1hzcm2s2wh5sapgr000lg63hcdbj6hyajxl43xa1x80kc5piqbyp";
  };

  patches = [
    # GTK: prefer using curl's intrinsic defaults for CURLOPT_CA*
    (fetchpatch {
	  name = "0001-GTK-prefer-using-curl-s-intrinsic-defaults-for-CURLO.patch";
      url = "http://source.netsurf-browser.org/netsurf.git/patch/?id=87177d8aa109206d131e0d80a2080ce55dab01c7";
      sha256 = "08bc60pc5k5qpckqv21zgmgszj3rpwskfc84shs8vg92vkimv2ai";
    })
  ];

  nativeBuildInputs = [
    makeWrapper
    perl
    perlPackages.HTMLParser
    pkgconfig
    xxd
  ]
  ++ optional (uilib == "gtk") wrapGAppsHook
  ;

  buildInputs = [ 
    check curl libXcursor libXrandr libidn libjpeg libpng libwebp libxml2 openssl
    # Netsurf-specific libraries
    nsgenbind libnsfb libwapcaplet libparserutils libnslog libcss
    libhubbub libdom libnsbmp libnsgif libsvgtiny libnsutils libnspsl
    libutf8proc
  ]
  ++ optionals (uilib == "framebuffer") [ expat SDL ]
  ++ optional (uilib == "gtk") gtk2
  ;

  preConfigure = ''
    cat <<EOF > Makefile.conf
    override NETSURF_GTK_RES_PATH  := $out/share/
    override NETSURF_USE_GRESOURCE := YES
    EOF
  '';

  makeFlags = [
    "PREFIX=${placeholder "out"}"
    "TARGET=${uilib}"
  ];

  meta = with stdenv.lib; {
    homepage = http://www.netsurf-browser.org/;
    description = "Free opensource web browser";
    license = licenses.gpl2;
    maintainers = [ maintainers.vrthra ];
    platforms = platforms.linux;
  };
}

{'fraction_non_alphanumeric': 0.12018329514684441, 'fraction_numerical': 0.03228494063736721, 'mean_word_length': 3.534466477809254, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2974362', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1857, 'n_words': 332}