<commit_before>{ stdenv, lib, fetchzip, cups }:

let
  platform =
    if stdenv.system == "x86_64-linux" then "64bit"
    else if stdenv.system == "i686-linux" then "32bit"
         else abort "Unsupported platform";

  libPath = lib.makeLibraryPath [ cups ];
in

stdenv.mkDerivation rec {
  name = "cups-kyocera-${version}";
  version = "1.1203";

  dontPatchELF = true;
  dontStrip = true;

  src = fetchzip {
    url = "http://cdn.kyostatics.net/dlc/ru/driver/all/linuxdrv_1_1203_fs-1x2xmfp.-downloadcenteritem-Single-File.downloadcenteritem.tmp/LinuxDrv_1.1203_FS-1x2xMFP.zip";
    sha256 = "0z1pbgidkibv4j21z0ys8cq1lafc6687syqa07qij2qd8zp15wiz";
  };

  installPhase = ''
    tar -xvf ${platform}/Global/English.tar.gz
    install -Dm755 English/rastertokpsl $out/lib/cups/filter/rastertokpsl
    patchelf \
      --set-rpath ${libPath} \
      --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
      $out/lib/cups/filter/rastertokpsl

    mkdir -p $out/share/cups/model/Kyocera
    cd English
    for i in *.ppd; do
      sed -i $i -e \
        "s,/usr/lib/cups/filter/rastertokpsl,$out/lib/cups/filter/rastertokpsl,g"
      cp $i $out/share/cups/model/Kyocera
    done;<commit_msg>cups-kyocera: fix downloading of source<commit_after>{ stdenv, lib, fetchzip, cups }:

let
  platform =
    if stdenv.system == "x86_64-linux" then "64bit"
    else if stdenv.system == "i686-linux" then "32bit"
         else abort "Unsupported platform";

  libPath = lib.makeLibraryPath [ cups ];
in

stdenv.mkDerivation rec {
  name = "cups-kyocera-${version}";
  version = "1.1203";

  dontPatchELF = true;
  dontStrip = true;

  src = fetchzip {
    # this side does not like curl -> override useragent
    curlOpts = "-A ''";
    url = "http://cdn.kyostatics.net/dlc/ru/driver/all/linuxdrv_1_1203_fs-1x2xmfp.-downloadcenteritem-Single-File.downloadcenteritem.tmp/LinuxDrv_1.1203_FS-1x2xMFP.zip";
    sha256 = "0z1pbgidkibv4j21z0ys8cq1lafc6687syqa07qij2qd8zp15wiz";
  };

  installPhase = ''
    tar -xvf ${platform}/Global/English.tar.gz
    install -Dm755 English/rastertokpsl $out/lib/cups/filter/rastertokpsl
    patchelf \
      --set-rpath ${libPath} \
      --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
      $out/lib/cups/filter/rastertokpsl

    mkdir -p $out/share/cups/model/Kyocera
    cd English
    for i in *.ppd; do
      sed -i $i -e \
        "s,/usr/lib/cups/filter/rastertokpsl,$out/lib/cups/filter/rastertokpsl,g"
      cp $i $out/share/cups/model/Kyocera
    done;
{'fraction_non_alphanumeric': 0.1364180295173514, 'fraction_numerical': 0.0430793777423215, 'mean_word_length': 3.0714285714285716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4321323', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1020, 'n_words': 165}