<commit_before>{ lib, stdenv, requireFile, unzip }:

stdenv.mkDerivation {
  pname = "input-fonts";
  version = "2019-11-25"; # date of the download and checksum

  src = requireFile {
    name = "Input-Font.zip";
    url = "https://input.fontbureau.com/download/";
    sha256 = "10rax2a7vzidcs7kyfg5lv5bwp9i7kvjpdcsd10p0517syijkp3b";
  };

  nativeBuildInputs = [ unzip ];

  phases = [ "unpackPhase" "installPhase" ];

  sourceRoot = ".";

  installPhase = ''
    mkdir -p $out/share/fonts/truetype
    find Input_Fonts -name "*.ttf" -exec cp -a {} "$out"/share/fonts/truetype/ \;
    mkdir -p "$out"/share/doc
    cp -a *.txt "$out"/share/doc/
  '';

  outputHashAlgo = "sha256";
  outputHashMode = "recursive";
  outputHash = "15sdhqqqd4jgk80fw7ncx49avi9cxbdgyrvnrfya0066x4q4r6lv";

  meta = with lib; {
    description = "Fonts for Code, from Font Bureau";
    longDescription = ''
      Input is a font family designed for computer programming, data,
      and text composition. It was designed by <NAME>
      between 2012 and 2014 and published by The Font Bureau. It
      contains a wide array of styles so you can fine-tune the
      typography that works best in your editing environment.

      Input Mono is a monospaced typeface, where all characters occupy
      a fixed width. Input Sans and Serif are proportional typefaces
      that are designed with all of the features of a good monospace —
      generous spacing, large punctuation, and easily distinguishable
      characters — but without the limitations of a fixed width.
    '';
    homepage = "https://input.fontbureau.com";
    license = licenses.unfree;
    maintainers = with maintainers; [ romildo ];<commit_msg>input-fonts: make Nix download the source<commit_after>{ lib
, stdenv
, fetchzip
, python3
, config
, acceptLicense ? config.input-fonts.acceptLicense or false
}:

let

  throwLicense = throw ''
    Input is available free of charge for private/unpublished usage. This includes things like your personal coding app or for composing plain text documents.
    To use it, you need to agree to its license: https://input.djr.com/license/

    You can express acceptance by setting acceptLicense to true in your
    configuration. Note that this is not a free license so it requires allowing
    unfree licenses.

    configuration.nix:
      nixpkgs.config.allowUnfree = true;
      nixpkgs.config.input-fonts.acceptLicense = true;

    config.nix:
      allowUnfree = true;
      input-fonts.acceptLicense = true;

    If you would like to support this project, consider purchasing a license at <http://input.djr.com/buy>.
  '';

  releaseDate = "2015-06-24";

in

stdenv.mkDerivation rec {
  pname = "input-fonts";
  version = "1.2";

  src =
    assert !acceptLicense -> throwLicense;
    fetchzip {
      name = "input-fonts-${version}";
      # Add .zip parameter so that zip unpackCmd can match it.
      url = "https://input.djr.com/build/?fontSelection=whole&a=0&g=0&i=0&l=0&zero=0&asterisk=0&braces=0&preset=default&line-height=1.2&accept=I+do&email=&.zip";
      sha256 = "BESZ4Bjgm2hvQ7oPpMvYSlE8EqvQjqHZtXWIovqyIzA=";
      stripRoot = false;

      extraPostFetch = ''
        # Reset the timestamp to release date for determinism.
        PATH=${lib.makeBinPath [ python3.pkgs.fonttools ]}:$PATH
        for ttf_file in $out/Input_Fonts/*/*/*.ttf; do
          ttx_file=$(dirname "$ttf_file")/$(basename "$ttf_file" .ttf).ttx
          ttx "$ttf_file"
          rm "$ttf_file"
          touch -m -t ${builtins.replaceStrings [ "-" ] [ "" ] releaseDate}0000 "$ttx_file"
          ttx --recalc-timestamp "$ttx_file"
          rm "$ttx_file"
        done
      '';
    };

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/fonts/truetype
    find Input_Fonts -name "*.ttf" -exec cp -a {} "$out"/share/fonts/truetype/ \;
    mkdir -p "$out"/share/doc
    cp -a *.txt "$out"/share/doc/

    runHook postInstall
  '';

  meta = with lib; {
    description = "Fonts for Code, from Font Bureau";
    longDescription = ''
      Input is a font family designed for computer programming, data,
      and text composition. It was designed by <NAME>
      between 2012 and 2014 and published by The Font Bureau. It
      contains a wide array of styles so you can fine-tune the
      typography that works best in your editing environment.

      Input Mono is a monospaced typeface, where all characters occupy
      a fixed width. Input Sans and Serif are proportional typefaces
      that are designed with all of the features of a good monospace —
      generous spacing, large punctuation, and easily distinguishable
      characters — but without the limitations of a fixed width.
    '';
    homepage = "https://input.djr.com/";
    license = licenses.unfree;
    maintainers = with maintainers; [
      jtojnar
      romildo
    ];
{'fraction_non_alphanumeric': 0.10055180870631514, 'fraction_numerical': 0.019211117923564277, 'mean_word_length': 2.946774193548387, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7543998', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1510, 'n_words': 488}