nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 72 lines 2.4 kB view raw
1{ stdenv 2, fetchurl 3, lib 4# To select only certain fonts, put a list of strings to `fonts`: every key in 5# ./shas.nix is an optional font 6, fonts ? [] 7# Whether to enable Windows font variants, their internal font name is limited 8# to 31 characters 9, enableWindowsFonts ? false 10}: 11 12let 13 # both of these files are generated via ./update.sh 14 version = import ./version.nix; 15 fontsShas = import ./shas.nix; 16 knownFonts = builtins.attrNames fontsShas; 17 selectedFonts = if (fonts == []) then 18 knownFonts 19 else 20 let unknown = lib.subtractLists knownFonts fonts; in 21 if (unknown != []) then 22 throw "Unknown font(s): ${lib.concatStringsSep " " unknown}" 23 else 24 fonts 25 ; 26 selectedFontsShas = lib.attrsets.genAttrs selectedFonts ( 27 fName: 28 fontsShas."${fName}" 29 ); 30 srcs = lib.attrsets.mapAttrsToList ( 31 fName: 32 fSha: 33 (fetchurl { 34 url = "https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${fName}.tar.xz"; 35 sha256 = fSha; 36 }) 37 ) selectedFontsShas; 38in 39 40stdenv.mkDerivation rec { 41 inherit version; 42 inherit srcs; 43 pname = "nerdfonts"; 44 sourceRoot = "."; 45 buildPhase = '' 46 echo "selected fonts are ${toString selectedFonts}" 47 ls *.otf *.ttf 48 ''; 49 installPhase = '' 50 find -name \*.otf -exec mkdir -p $out/share/fonts/opentype/NerdFonts \; -exec mv {} $out/share/fonts/opentype/NerdFonts \; 51 find -name \*.ttf -exec mkdir -p $out/share/fonts/truetype/NerdFonts \; -exec mv {} $out/share/fonts/truetype/NerdFonts \; 52 ${lib.optionalString (! enableWindowsFonts) '' 53 rm -rfv $out/share/fonts/opentype/NerdFonts/*Windows\ Compatible.* 54 rm -rfv $out/share/fonts/truetype/NerdFonts/*Windows\ Compatible.* 55 ''} 56 ''; 57 passthru.updateScript = ./update.sh; 58 59 meta = with lib; { 60 description = "Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts"; 61 longDescription = '' 62 Nerd Fonts is a project that attempts to patch as many developer targeted 63 and/or used fonts as possible. The patch is to specifically add a high 64 number of additional glyphs from popular 'iconic fonts' such as Font 65 Awesome, Devicons, Octicons, and others. 66 ''; 67 homepage = "https://nerdfonts.com/"; 68 license = licenses.mit; 69 maintainers = with maintainers; [ doronbehar ]; 70 hydraPlatforms = []; # 'Output limit exceeded' on Hydra 71 }; 72}