nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, scfbuild
6, fontforge
7, libuninameslist
8, nodejs
9, nodePackages
10, python3Packages
11, variant ? "color" # "color" or "black"
12}:
13
14let
15 filename = builtins.replaceStrings
16 [ "color" "black" ]
17 [ "OpenMoji-Color.ttf" "OpenMoji-Black.ttf" ]
18 variant;
19
20 # With newer fontforge the build hangs, see
21 # https://github.com/NixOS/nixpkgs/issues/167869
22 # Patches etc taken from
23 # https://github.com/NixOS/nixpkgs/commit/69da642a5a9bb433138ba1b13c8d56fb5bb6ec05
24 fontforge-20201107 = fontforge.overrideAttrs (old: rec {
25 version = "20201107";
26 src = fetchFromGitHub {
27 owner = "fontforge";
28 repo = "fontforge";
29 rev = version;
30 sha256 = "sha256-Rl/5lbXaPgIndANaD0IakaDus6T53FjiBb45FIuGrvc=";
31 };
32 patches = [
33 (fetchpatch {
34 url = "https://salsa.debian.org/fonts-team/fontforge/raw/76bffe6ccf8ab20a0c81476a80a87ad245e2fd1c/debian/patches/0001-add-extra-cmake-install-rules.patch";
35 sha256 = "u3D9od2xLECNEHhZ+8dkuv9818tPkdP6y/Tvd9CADJg=";
36 })
37 (fetchpatch {
38 url = "https://github.com/fontforge/fontforge/commit/69e263b2aff29ad22f97f13935cfa97a1eabf207.patch";
39 sha256 = "06yyf90605aq6ppfiz83mqkdmnaq5418axp9jgsjyjq78b00xb29";
40 })
41 ];
42 buildInputs = old.buildInputs ++ [ libuninameslist ];
43 });
44 scfbuild-with-fontforge-20201107 = scfbuild.override (old: {
45 fontforge = fontforge-20201107;
46 });
47
48in stdenv.mkDerivation rec {
49 pname = "openmoji";
50 version = "14.0.0";
51
52 src = fetchFromGitHub {
53 owner = "hfg-gmuend";
54 repo = pname;
55 rev = version;
56 sha256 = "sha256-XnSRSlWXOMeSaO6dKaOloRg3+sWS4BSaro4bPqOyKmE=";
57 };
58
59 nativeBuildInputs = [
60 scfbuild-with-fontforge-20201107
61 nodejs
62 nodePackages.glob
63 nodePackages.lodash
64 ];
65
66 postPatch = ''
67 # this is API change in glob >9
68 substituteInPlace helpers/generate-font-glyphs.js \
69 --replace "require('glob').sync" "require('glob').globSync"
70 '';
71
72 buildPhase = ''
73 runHook preBuild
74
75 node helpers/generate-font-glyphs.js
76
77 cd font
78 scfbuild -c scfbuild-${variant}.yml
79
80 runHook postBuild
81 '';
82
83 installPhase = ''
84 install -Dm644 ${filename} $out/share/fonts/truetype/${filename}
85 '';
86
87 meta = with lib; {
88 license = licenses.cc-by-sa-40;
89 maintainers = with maintainers; [ fgaz ];
90 platforms = platforms.all;
91 homepage = "https://openmoji.org/";
92 downloadPage = "https://github.com/hfg-gmuend/openmoji/releases";
93 description = "Open-source emojis for designers, developers and everyone else";
94 };
95}