2021-09-18 10:52:07 +00:00
|
|
|
{ lib
|
2024-04-21 15:54:59 +00:00
|
|
|
, stdenvNoCC
|
2021-09-18 10:52:07 +00:00
|
|
|
, fetchFromGitHub
|
2024-04-21 15:54:59 +00:00
|
|
|
, nanoemoji
|
2021-09-18 10:52:07 +00:00
|
|
|
, python3Packages
|
2024-04-21 15:54:59 +00:00
|
|
|
, woff2
|
|
|
|
, xmlstarlet
|
|
|
|
# available color formats: ["cbdt" "glyf_colr_0" "glyf_colr_1" "sbix" "picosvgz" "untouchedsvgz"]
|
|
|
|
# available black formats: ["glyf"]
|
|
|
|
, fontFormats ? [ "glyf" "cbdt" "glyf_colr_0" "glyf_colr_1" ]
|
|
|
|
# when at least one of the glyf_colr_0/1 formats is specified, whether to build maximum color fonts
|
|
|
|
# "none" to not build any, "svg" to build colr+svg, "bitmap" to build cbdt+colr+svg fonts
|
|
|
|
, buildMaximumColorFonts ? "bitmap"
|
2021-09-18 10:52:07 +00:00
|
|
|
}:
|
|
|
|
let
|
2024-04-21 15:54:59 +00:00
|
|
|
# all available methods
|
|
|
|
methods = {
|
|
|
|
black = [ "glyf" ];
|
|
|
|
color = [ "cbdt" "glyf_colr_0" "glyf_colr_1" "sbix" "picosvgz" "untouchedsvgz" ];
|
|
|
|
};
|
|
|
|
in
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
assert lib.asserts.assertEachOneOf "fontFormats" fontFormats (methods.black ++ methods.color);
|
|
|
|
assert lib.asserts.assertOneOf "buildMaximumColorFonts" buildMaximumColorFonts [ "none" "bitmap" "svg" ];
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
stdenvNoCC.mkDerivation rec {
|
2021-09-18 10:52:07 +00:00
|
|
|
pname = "openmoji";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "15.0.0";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "hfg-gmuend";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-659ONkHU45Z2789ay0yLero9j5nFWhslpJad++4oNN8=";
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
patches = [
|
|
|
|
# fix paths and variables for nix build and skip generating font demos
|
|
|
|
./build.patch
|
|
|
|
];
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
nativeBuildInputs = [
|
2024-04-21 15:54:59 +00:00
|
|
|
nanoemoji
|
|
|
|
python3Packages.fonttools
|
|
|
|
woff2
|
|
|
|
xmlstarlet
|
2021-09-18 10:52:07 +00:00
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
methods_black = builtins.filter (m: builtins.elem m fontFormats) methods.black;
|
|
|
|
methods_color = builtins.filter (m: builtins.elem m fontFormats) methods.color;
|
|
|
|
saturations = lib.optional (methods_black != [ ]) "black" ++ lib.optional (methods_color != [ ]) "color";
|
|
|
|
maximumColorVersions = lib.optionals (buildMaximumColorFonts != "none") (
|
|
|
|
lib.optional (builtins.elem "glyf_colr_0" fontFormats) "0"
|
|
|
|
++ lib.optional (builtins.elem "glyf_colr_1" fontFormats) "1"
|
|
|
|
);
|
|
|
|
|
|
|
|
postPatch = lib.optionalString (buildMaximumColorFonts == "bitmap") ''
|
|
|
|
substituteInPlace helpers/generate-fonts-runner.sh \
|
|
|
|
--replace 'maximum_color' 'maximum_color --bitmaps'
|
2023-03-15 16:39:30 +00:00
|
|
|
'';
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
bash helpers/generate-fonts-runner.sh "$(pwd)/build" "${version}"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2024-04-21 15:54:59 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/share/fonts/truetype $out/share/fonts/woff2
|
|
|
|
cp build/fonts/*/*.ttf $out/share/fonts/truetype/
|
|
|
|
cp build/fonts/*/*.woff2 $out/share/fonts/woff2/
|
|
|
|
|
|
|
|
runHook postInstall
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.cc-by-sa-40;
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with maintainers; [ _999eagle fgaz ];
|
2021-09-18 10:52:07 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
homepage = "https://openmoji.org/";
|
|
|
|
downloadPage = "https://github.com/hfg-gmuend/openmoji/releases";
|
|
|
|
description = "Open-source emojis for designers, developers and everyone else";
|
|
|
|
};
|
|
|
|
}
|