Merge pull request #118665 from jtojnar/input

input-fonts: make Nix download the source

authored by Jan Tojnar and committed by GitHub 5a80eca0 f7ff8747

+66 -18
+66 -18
pkgs/data/fonts/input-fonts/default.nix
··· 1 - { lib, stdenv, requireFile, unzip }: 1 + { lib 2 + , stdenv 3 + , fetchzip 4 + , python3 5 + , config 6 + , acceptLicense ? config.input-fonts.acceptLicense or false 7 + }: 2 8 3 - stdenv.mkDerivation { 4 - pname = "input-fonts"; 5 - version = "2019-11-25"; # date of the download and checksum 9 + let 6 10 7 - src = requireFile { 8 - name = "Input-Font.zip"; 9 - url = "https://input.fontbureau.com/download/"; 10 - sha256 = "10rax2a7vzidcs7kyfg5lv5bwp9i7kvjpdcsd10p0517syijkp3b"; 11 - }; 11 + throwLicense = throw '' 12 + Input is available free of charge for private/unpublished usage. This includes things like your personal coding app or for composing plain text documents. 13 + To use it, you need to agree to its license: https://input.djr.com/license/ 12 14 13 - nativeBuildInputs = [ unzip ]; 15 + You can express acceptance by setting acceptLicense to true in your 16 + configuration. Note that this is not a free license so it requires allowing 17 + unfree licenses. 18 + 19 + configuration.nix: 20 + nixpkgs.config.allowUnfree = true; 21 + nixpkgs.config.input-fonts.acceptLicense = true; 22 + 23 + config.nix: 24 + allowUnfree = true; 25 + input-fonts.acceptLicense = true; 14 26 15 - phases = [ "unpackPhase" "installPhase" ]; 27 + If you would like to support this project, consider purchasing a license at <http://input.djr.com/buy>. 28 + ''; 16 29 17 - sourceRoot = "."; 30 + releaseDate = "2015-06-24"; 31 + 32 + in 33 + 34 + stdenv.mkDerivation rec { 35 + pname = "input-fonts"; 36 + version = "1.2"; 37 + 38 + src = 39 + assert !acceptLicense -> throwLicense; 40 + fetchzip { 41 + name = "input-fonts-${version}"; 42 + # Add .zip parameter so that zip unpackCmd can match it. 43 + 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"; 44 + sha256 = "BESZ4Bjgm2hvQ7oPpMvYSlE8EqvQjqHZtXWIovqyIzA="; 45 + stripRoot = false; 46 + 47 + extraPostFetch = '' 48 + # Reset the timestamp to release date for determinism. 49 + PATH=${lib.makeBinPath [ python3.pkgs.fonttools ]}:$PATH 50 + for ttf_file in $out/Input_Fonts/*/*/*.ttf; do 51 + ttx_file=$(dirname "$ttf_file")/$(basename "$ttf_file" .ttf).ttx 52 + ttx "$ttf_file" 53 + rm "$ttf_file" 54 + touch -m -t ${builtins.replaceStrings [ "-" ] [ "" ] releaseDate}0000 "$ttx_file" 55 + ttx --recalc-timestamp "$ttx_file" 56 + rm "$ttx_file" 57 + done 58 + ''; 59 + }; 60 + 61 + dontConfigure = true; 62 + dontBuild = true; 18 63 19 64 installPhase = '' 65 + runHook preInstall 66 + 20 67 mkdir -p $out/share/fonts/truetype 21 68 find Input_Fonts -name "*.ttf" -exec cp -a {} "$out"/share/fonts/truetype/ \; 22 69 mkdir -p "$out"/share/doc 23 70 cp -a *.txt "$out"/share/doc/ 71 + 72 + runHook postInstall 24 73 ''; 25 74 26 - outputHashAlgo = "sha256"; 27 - outputHashMode = "recursive"; 28 - outputHash = "15sdhqqqd4jgk80fw7ncx49avi9cxbdgyrvnrfya0066x4q4r6lv"; 29 - 30 75 meta = with lib; { 31 76 description = "Fonts for Code, from Font Bureau"; 32 77 longDescription = '' ··· 42 87 generous spacing, large punctuation, and easily distinguishable 43 88 characters — but without the limitations of a fixed width. 44 89 ''; 45 - homepage = "https://input.fontbureau.com"; 90 + homepage = "https://input.djr.com/"; 46 91 license = licenses.unfree; 47 - maintainers = with maintainers; [ romildo ]; 92 + maintainers = with maintainers; [ 93 + jtojnar 94 + romildo 95 + ]; 48 96 platforms = platforms.all; 49 97 }; 50 98 }