about summary refs log tree commit diff
path: root/pkgs/by-name/no/noto-fonts-monochrome-emoji/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/no/noto-fonts-monochrome-emoji/package.nix')
-rw-r--r--pkgs/by-name/no/noto-fonts-monochrome-emoji/package.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/pkgs/by-name/no/noto-fonts-monochrome-emoji/package.nix b/pkgs/by-name/no/noto-fonts-monochrome-emoji/package.nix
new file mode 100644
index 000000000000..08f78b613efc
--- /dev/null
+++ b/pkgs/by-name/no/noto-fonts-monochrome-emoji/package.nix
@@ -0,0 +1,53 @@
+{ 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 ];
+  };
+}