depot/third_party/nixpkgs/pkgs/by-name/no/noto-fonts-monochrome-emoji/package.nix
Default email 504525a148 Project import generated by Copybara.
GitOrigin-RevId: bd645e8668ec6612439a9ee7e71f7eac4099d4f6
2024-01-02 12:29:13 +01:00

53 lines
1.3 KiB
Nix

{ lib
, stdenvNoCC
, fetchurl
}:
# Metadata fetched from
# https://www.googleapis.com/webfonts/v1/webfonts?key=${GOOGLE_FONTS_TOKEN}&family=Noto+Emoji
let
metadata = with builtins; head (fromJSON (readFile ./noto-emoji.json)).items;
urlHashes = with builtins; fromJSON (readFile ./noto-emoji.hashes.json);
in
stdenvNoCC.mkDerivation {
pname = "noto-fonts-monochrome-emoji";
version = "${lib.removePrefix "v" metadata.version}.${metadata.lastModified}";
preferLocalBuild = true;
dontUnpack = true;
srcs =
let
weightNames = {
"300" = "Light";
regular = "Regular";
"500" = "Medium";
"600" = "SemiBold";
"700" = "Bold";
};
in
lib.mapAttrsToList
(variant: url: fetchurl {
name = "NotoEmoji-${weightNames.${variant}}.ttf";
hash = urlHashes.${url};
inherit url;
})
metadata.files;
installPhase = ''
runHook preInstall
for src in $srcs; do
install -D $src $out/share/fonts/noto/$(stripHash $src)
done
runHook postInstall
'';
meta = {
description = "Monochrome emoji font";
homepage = "https://fonts.google.com/noto/specimen/Noto+Emoji";
license = [ lib.licenses.ofl ];
maintainers = [ lib.maintainers.nicoo ];
platforms = lib.platforms.all;
sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
};
}