<commit_before>{ swingSupport ? true
, stdenv
, requireFile
, makeWrapper
, unzip
, file
, xorg ? null
, packageType ? "JDK" # JDK, JRE, or ServerJRE
, pluginSupport ? true
, installjce ? false
, glib
, libxml2
, ffmpeg_2
, libxslt
, mesa_noglu
, freetype
, fontconfig
, gtk2
, pango
, cairo
, alsaLib
, atk
, gdk_pixbuf
, zlib
, elfutils
, setJavaClassPath
}:

assert stdenv.system == "x86_64-linux";
assert swingSupport -> xorg != null;

let
  version = "9.0.1";

  downloadUrlBase = http://www.oracle.com/technetwork/java/javase/downloads;

  jce =
    if installjce then
      requireFile {
        name = "jce_policy-8.zip";
        url = "${downloadUrlBase}/jce8-download-2133166.html";
        sha256 = "0n8b6b8qmwb14lllk2lk1q1ahd3za9fnjigz5xn65mpg48whl0pk";
      }
    else
      "";

  rSubPaths = [
    "lib/jli"
    "lib/server"
    "lib"
  ];

in

let result = stdenv.mkDerivation rec {
  name = if packageType == "JDK"       then "oraclejdk-${version}"
    else if packageType == "JRE"       then "oraclejre-${version}"
    else if packageType == "ServerJRE" then "oracleserverjre-${version}"
    else abort "unknown package Type ${packageType}";

  src =
    if packageType == "JDK" then
      requireFile {
        name = "jdk-${version}_linux-x64_bin.tar.gz";
        url =  "${downloadUrlBase}/jdk9-downloads-3848520.html";
        sha256 = "0560dc3icrwb0ifykshvzkr04b1jr153m26x1r8rp0nhjbzz1nic";
      }
    else if packageType == "JRE" then
      requireFile {
        name = "jre-${version}_linux-x64_bin.tar.gz";
        url = "${downloadUrlBase}/jre9-downloads-3848532.html";
        sha256 = "11pfcck8am48yv7riaj10g6h79xdiy8lm5a9wjqbm3g9cls9ar1w";
      }
    else if packageType == "ServerJRE" then
      requireFile {
        name = "serverjre-${version}_linux-x64_bin.tar.gz";
        url = "${downloadUrlBase}/server-jre9-downloads-3848530.html";
        sha256 = "1biyks6jy0a2kksaj9qbsjifv34ym5mdw8akibmkwr1xh0wavygc";
      }
    else abort "unknown package Type ${packageType}";

  nativeBuildInputs = [ file ]
    ++ stdenv.lib.optional installjce unzip;

  buildInputs = [ makeWrapper ];

  # See: https://github.com/NixOS/patchelf/issues/10
  dontStrip = 1;

  installPhase = ''
    cd ..

    # Set PaX markings
    exes=$(file $sourceRoot/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
    for file in $exes; do
      paxmark m "$file"
      # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well.
      ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''}
    done

    mv $sourceRoot $out

    shopt -s extglob
    for file in $out/*
    do
      if test -f $file ; then
        rm $file
      fi
    done

    if test -n "${jce}"; then
      unzip ${jce}
      cp -v UnlimitedJCEPolicy*/*.jar $out/lib/security
    fi

    if test -z "$pluginSupport"; then
      rm -f $out/bin/javaws
    fi

    mkdir $out/lib/plugins
    ln -s $out/lib/libnpjp2.so $out/lib/plugins

    # for backward compatibility
    ln -s $out $out/jre

    mkdir -p $out/nix-support
    printWords ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs

    # Set JAVA_HOME automatically.
    cat <<EOF >> $out/nix-support/setup-hook
    if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi
    EOF
  '';<commit_msg>oraclejdk: remove JCE option<commit_after>{ swingSupport ? true
, stdenv
, requireFile
, makeWrapper
, unzip
, file
, xorg ? null
, packageType ? "JDK" # JDK, JRE, or ServerJRE
, pluginSupport ? true
, glib
, libxml2
, ffmpeg_2
, libxslt
, mesa_noglu
, freetype
, fontconfig
, gtk2
, pango
, cairo
, alsaLib
, atk
, gdk_pixbuf
, zlib
, elfutils
, setJavaClassPath
}:

assert stdenv.system == "x86_64-linux";
assert swingSupport -> xorg != null;

let
  version = "9.0.1";

  downloadUrlBase = http://www.oracle.com/technetwork/java/javase/downloads;

  rSubPaths = [
    "lib/jli"
    "lib/server"
    "lib"
  ];

in

let result = stdenv.mkDerivation rec {
  name = if packageType == "JDK"       then "oraclejdk-${version}"
    else if packageType == "JRE"       then "oraclejre-${version}"
    else if packageType == "ServerJRE" then "oracleserverjre-${version}"
    else abort "unknown package Type ${packageType}";

  src =
    if packageType == "JDK" then
      requireFile {
        name = "jdk-${version}_linux-x64_bin.tar.gz";
        url =  "${downloadUrlBase}/jdk9-downloads-3848520.html";
        sha256 = "0560dc3icrwb0ifykshvzkr04b1jr153m26x1r8rp0nhjbzz1nic";
      }
    else if packageType == "JRE" then
      requireFile {
        name = "jre-${version}_linux-x64_bin.tar.gz";
        url = "${downloadUrlBase}/jre9-downloads-3848532.html";
        sha256 = "11pfcck8am48yv7riaj10g6h79xdiy8lm5a9wjqbm3g9cls9ar1w";
      }
    else if packageType == "ServerJRE" then
      requireFile {
        name = "serverjre-${version}_linux-x64_bin.tar.gz";
        url = "${downloadUrlBase}/server-jre9-downloads-3848530.html";
        sha256 = "1biyks6jy0a2kksaj9qbsjifv34ym5mdw8akibmkwr1xh0wavygc";
      }
    else abort "unknown package Type ${packageType}";

  nativeBuildInputs = [ file ];

  buildInputs = [ makeWrapper ];

  # See: https://github.com/NixOS/patchelf/issues/10
  dontStrip = 1;

  installPhase = ''
    cd ..

    # Set PaX markings
    exes=$(file $sourceRoot/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
    for file in $exes; do
      paxmark m "$file"
      # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well.
      ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''}
    done

    mv $sourceRoot $out

    shopt -s extglob
    for file in $out/*
    do
      if test -f $file ; then
        rm $file
      fi
    done

    if test -z "$pluginSupport"; then
      rm -f $out/bin/javaws
    fi

    mkdir $out/lib/plugins
    ln -s $out/lib/libnpjp2.so $out/lib/plugins

    # for backward compatibility
    ln -s $out $out/jre

    mkdir -p $out/nix-support
    printWords ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs

    # Set JAVA_HOME automatically.
    cat <<EOF >> $out/nix-support/setup-hook
    if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi
    EOF
  '';
{'fraction_non_alphanumeric': 0.12923967207844397, 'fraction_numerical': 0.039704227616138885, 'mean_word_length': 2.7731958762886597, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5521210', 'n_tokens_mistral': 2519, 'n_tokens_neox': 2345, 'n_words': 500}