Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 103 lines 2.9 kB view raw
1{ 2 lib, 3 stdenvNoCC, 4 fetchurl, 5}: 6 7let 8 releaseInfo = lib.trivial.importJSON ./manifests/release.json; 9 fontsInfo = lib.trivial.importJSON ./manifests/fonts.json; 10 checksums = lib.trivial.importJSON ./manifests/checksums.json; 11 12 releaseVersion = lib.removePrefix "v" releaseInfo.tag_name; 13 14 convertAttrName = 15 name: 16 let 17 lowerName = lib.strings.toLower name; 18 in 19 if builtins.match "^[[:digit:]].*" lowerName != null then "_" + lowerName else lowerName; 20 21 convertVersion = 22 version: if builtins.match "^[[:digit:]].*" version != null then "+" + version else ""; 23 24 convertLicense = import ./convert-license.nix lib; 25 26 makeNerdFont = 27 { 28 caskName, 29 description, 30 folderName, 31 licenseId, 32 patchedName, 33 version, 34 ... 35 }: 36 stdenvNoCC.mkDerivation { 37 pname = "nerd-fonts-" + lib.strings.toLower caskName; 38 version = releaseVersion + convertVersion version; 39 40 src = 41 let 42 filename = folderName + ".tar.xz"; 43 url = "https://github.com/ryanoasis/nerd-fonts/releases/download/${releaseInfo.tag_name}/${filename}"; 44 sha256 = checksums.${filename}; 45 in 46 fetchurl { 47 inherit url sha256; 48 }; 49 50 sourceRoot = "."; 51 52 installPhase = 53 let 54 dirName = lib.strings.concatStrings (lib.strings.splitString " " patchedName); 55 in 56 '' 57 runHook preInstall 58 59 dst_opentype=$out/share/fonts/opentype/NerdFonts/${dirName} 60 dst_truetype=$out/share/fonts/truetype/NerdFonts/${dirName} 61 62 find -name \*.otf -exec mkdir -p $dst_opentype \; -exec cp -p {} $dst_opentype \; 63 find -name \*.ttf -exec mkdir -p $dst_truetype \; -exec cp -p {} $dst_truetype \; 64 65 runHook postInstall 66 ''; 67 68 passthru = { 69 inherit releaseVersion; 70 updateScript = { 71 command = ./update.py; 72 supportedFeatures = [ "commit" ]; 73 }; 74 }; 75 76 meta = { 77 description = "Nerd Fonts: " + description; 78 license = lib.unique ( 79 (with lib.licenses; [ 80 # > Nerd Fonts source fonts, patched fonts, and folders with explicit OFL SIL files 81 ofl 82 # > Nerd Fonts original source code files (such as `.sh`, `.py`, `font-patcher` and others) 83 mit 84 ]) 85 ++ lib.toList (convertLicense licenseId) 86 ); 87 homepage = "https://nerdfonts.com/"; 88 changelog = "https://github.com/ryanoasis/nerd-fonts/blob/${releaseInfo.tag_name}/changelog.md"; 89 platforms = lib.platforms.all; 90 maintainers = with lib.maintainers; [ 91 doronbehar 92 rc-zb 93 ]; 94 }; 95 }; 96 97 nerdFonts = lib.trivial.pipe fontsInfo [ 98 (map (font: lib.nameValuePair (convertAttrName font.caskName) (makeNerdFont font))) 99 builtins.listToAttrs 100 ]; 101in 102 103nerdFonts