<commit_before>{ stdenv
, fetchurl
, dimensions ? 6 # works for <= dimensions dimensions, but is only optimized for that exact value
, doSymlink ? true # symlink the executables to the default location (without dimension postfix)
}:

stdenv.mkDerivation rec {
  version = "2.1";
  dim = toString dimensions;
  name = "palp-${dim}d-${version}";

  src = fetchurl {
    url = "http://hep.itp.tuwien.ac.at/~kreuzer/CY/palp/palp-${version}.tar.gz";
    sha256 = "1s7s2lc5f0ig1yy7ygsh3sddm3sbq4mxwybqsj8lp9wjdxs7qfrs";
  };

  hardeningDisable = [ "format" ];

  preBuild = ''
      echo Building PALP optimized for ${dim} dimensions
      sed -i "s/^#define[^a-zA-Z]*POLY_Dmax.*/#define POLY_Dmax ${dim}/" Global.h
  '';

  installPhase = ''
    mkdir -p "$out/bin"
    for file in poly class cws nef mori; do
        cp -p $file.x "$out/bin/$file-${dim}d.x"<commit_msg>palp: fix runtime error introduced by #28029 (#42633)<commit_after>{ stdenv
, fetchurl
, dimensions ? 6 # works for <= dimensions dimensions, but is only optimized for that exact value
, doSymlink ? true # symlink the executables to the default location (without dimension postfix)
}:

stdenv.mkDerivation rec {
  version = "2.1";
  dim = toString dimensions;
  name = "palp-${dim}d-${version}";

  src = fetchurl {
    url = "http://hep.itp.tuwien.ac.at/~kreuzer/CY/palp/palp-${version}.tar.gz";
    sha256 = "1s7s2lc5f0ig1yy7ygsh3sddm3sbq4mxwybqsj8lp9wjdxs7qfrs";
  };

  hardeningDisable = [
    "format"
    "strictoverflow" # causes runtime failure (tested in checkPhase)
  ];

  preBuild = ''
      echo Building PALP optimized for ${dim} dimensions
      sed -i "s/^#define[^a-zA-Z]*POLY_Dmax.*/#define POLY_Dmax ${dim}/" Global.h
  '';

  # palp has no tests of its own. This test is an adapted sage test that failed
  # when #28029 was merged.
  doCheck = true;
  checkPhase = ''
    ./nef.x -f -N << EOF | grep -q 'np='
      3 6
      1  0  0 -1  0  0
      0  1  0  0 -1  0
      0  0  1  0  0 -1
    EOF
  '';

  installPhase = ''
    mkdir -p "$out/bin"
    for file in poly class cws nef mori; do
        cp -p $file.x "$out/bin/$file-${dim}d.x"
{'fraction_non_alphanumeric': 0.13828786453433678, 'fraction_numerical': 0.03433678269049859, 'mean_word_length': 2.9461966604823746, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3513237', 'n_tokens_mistral': 849, 'n_tokens_neox': 804, 'n_words': 218}