at master 109 lines 2.8 kB view raw
1{ 2 lib, 3 stdenvNoCC, 4 fetchFromGitHub, 5 nanoemoji, 6 python3Packages, 7 woff2, 8 xmlstarlet, 9 # available color formats: ["cbdt" "glyf_colr_0" "glyf_colr_1" "sbix" "picosvgz" "untouchedsvgz"] 10 # available black formats: ["glyf"] 11 fontFormats ? [ 12 "glyf" 13 "cbdt" 14 "glyf_colr_0" 15 "glyf_colr_1" 16 ], 17 # when at least one of the glyf_colr_0/1 formats is specified, whether to build maximum color fonts 18 # "none" to not build any, "svg" to build colr+svg, "bitmap" to build cbdt+colr+svg fonts 19 buildMaximumColorFonts ? "bitmap", 20}: 21let 22 # all available methods 23 methods = { 24 black = [ "glyf" ]; 25 color = [ 26 "cbdt" 27 "glyf_colr_0" 28 "glyf_colr_1" 29 "sbix" 30 "picosvgz" 31 "untouchedsvgz" 32 ]; 33 }; 34in 35 36assert lib.asserts.assertEachOneOf "fontFormats" fontFormats (methods.black ++ methods.color); 37assert lib.asserts.assertOneOf "buildMaximumColorFonts" buildMaximumColorFonts [ 38 "none" 39 "bitmap" 40 "svg" 41]; 42 43stdenvNoCC.mkDerivation rec { 44 pname = "openmoji"; 45 version = "16.0.0"; 46 47 src = fetchFromGitHub { 48 owner = "hfg-gmuend"; 49 repo = "openmoji"; 50 rev = version; 51 hash = "sha256-4dYtLaABu88z25Ud/cuOECajxSJWR01qcTIZNWN7Fhw="; 52 }; 53 54 patches = [ 55 # fix paths and variables for nix build and skip generating font demos 56 ./build.patch 57 ]; 58 59 nativeBuildInputs = [ 60 nanoemoji 61 python3Packages.fonttools 62 woff2 63 xmlstarlet 64 ]; 65 66 methods_black = builtins.filter (m: builtins.elem m fontFormats) methods.black; 67 methods_color = builtins.filter (m: builtins.elem m fontFormats) methods.color; 68 saturations = 69 lib.optional (methods_black != [ ]) "black" ++ lib.optional (methods_color != [ ]) "color"; 70 maximumColorVersions = lib.optionals (buildMaximumColorFonts != "none") ( 71 lib.optional (builtins.elem "glyf_colr_0" fontFormats) "0" 72 ++ lib.optional (builtins.elem "glyf_colr_1" fontFormats) "1" 73 ); 74 75 postPatch = lib.optionalString (buildMaximumColorFonts == "bitmap") '' 76 substituteInPlace helpers/generate-fonts-runner.sh \ 77 --replace 'maximum_color' 'maximum_color --bitmaps' 78 ''; 79 80 buildPhase = '' 81 runHook preBuild 82 83 bash helpers/generate-fonts-runner.sh "$(pwd)/build" "${version}" 84 85 runHook postBuild 86 ''; 87 88 installPhase = '' 89 runHook preInstall 90 91 mkdir -p $out/share/fonts/truetype $out/share/fonts/woff2 92 cp build/fonts/*/*.ttf $out/share/fonts/truetype/ 93 cp build/fonts/*/*.woff2 $out/share/fonts/woff2/ 94 95 runHook postInstall 96 ''; 97 98 meta = with lib; { 99 license = licenses.cc-by-sa-40; 100 maintainers = with maintainers; [ 101 _999eagle 102 fgaz 103 ]; 104 platforms = platforms.all; 105 homepage = "https://openmoji.org/"; 106 downloadPage = "https://github.com/hfg-gmuend/openmoji/releases"; 107 description = "Open-source emojis for designers, developers and everyone else"; 108 }; 109}