<commit_before>{ stdenv, R, libcxx, xvfb_run, utillinux, Cocoa, Foundation, gettext, gfortran }:

{ name, buildInputs ? [], ... } @ attrs:

stdenv.mkDerivation ({
  buildInputs = buildInputs ++ [R gettext] ++
                stdenv.lib.optionals attrs.requireX [utillinux xvfb_run] ++
                stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation gfortran];

  NIX_CFLAGS_COMPILE =
    stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";

  configurePhase = ''
    runHook preConfigure
    export R_LIBS_SITE="$R_LIBS_SITE''${R_LIBS_SITE:+:}$out/library"
    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild
    runHook postBuild
  '';

  installFlags = if attrs.doCheck or true then
    []
  else
    [ "--no-test-load" ];

  rCommand = if attrs.requireX or false then<commit_msg>rPackages.buildRPackage: fix error if requireX is missing<commit_after>{ stdenv, R, libcxx, xvfb_run, utillinux, Cocoa, Foundation, gettext, gfortran }:

{ name, buildInputs ? [], requireX ? false, ... } @ attrs:

stdenv.mkDerivation ({
  buildInputs = buildInputs ++ [R gettext] ++
                stdenv.lib.optionals requireX [utillinux xvfb_run] ++
                stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation gfortran];

  NIX_CFLAGS_COMPILE =
    stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";

  configurePhase = ''
    runHook preConfigure
    export R_LIBS_SITE="$R_LIBS_SITE''${R_LIBS_SITE:+:}$out/library"
    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild
    runHook postBuild
  '';

  installFlags = if attrs.doCheck or true then
    []
  else
    [ "--no-test-load" ];

  rCommand = if requireX then
{'fraction_non_alphanumeric': 0.125956444967628, 'fraction_numerical': 0.0011771630370806356, 'mean_word_length': 3.3256997455470736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3740399', 'n_tokens_mistral': 630, 'n_tokens_neox': 617, 'n_words': 119}