diff --git a/pkgs/tools/misc/nanoemoji/default.nix b/pkgs/tools/misc/nanoemoji/default.nix new file mode 100644 index 000000000000..0e584bc978aa --- /dev/null +++ b/pkgs/tools/misc/nanoemoji/default.nix @@ -0,0 +1,72 @@ +{ lib +, python3 +, fetchFromGitHub +, resvg +, pngquant +}: +python3.pkgs.buildPythonApplication rec { + pname = "nanoemoji"; + version = "0.15.1"; + + src = fetchFromGitHub { + owner = "googlefonts"; + repo = pname; + rev = "v${version}"; + hash = "sha256-P/lT0PnjTdYzyttICzszu4OL5kj+X8GHZ8doL3tpXQM="; + }; + patches = [ + # this is necessary because the tests clear PATH/PYTHONPATH otherwise + ./test-pythonpath.patch + # minor difference in the test output, most likely due to different dependency versions + ./fix-test.patch + ]; + + nativeBuildInputs = with python3.pkgs; [ + setuptools-scm + pythonRelaxDepsHook + + pngquant + resvg + ]; + + # these two packages are just prebuilt wheels containing the respective binaries + pythonRemoveDeps = [ "pngquant-cli" "resvg-cli" ]; + + propagatedBuildInputs = with python3.pkgs; [ + absl-py + fonttools + lxml + ninja-python + picosvg + pillow + regex + toml + tomlkit + ufo2ft + ufoLib2 + zopfli + ]; + + nativeCheckInputs = with python3.pkgs; [ + pytestCheckHook + + ninja-python + picosvg + ]; + + makeWrapperArgs = [ + "--prefix PATH : ${lib.makeBinPath [ pngquant resvg ]}" + ]; + + preCheck = '' + # make sure the built binaries (nanoemoji/maximum_color) can be found by the test + export PATH="$out/bin:''${PATH}" + ''; + + meta = with lib; { + description = "A wee tool to build color fonts"; + homepage = "https://github.com/googlefonts/nanoemoji"; + license = licenses.asl20; + maintainers = with maintainers; [ _999eagle ]; + }; +} diff --git a/pkgs/tools/misc/nanoemoji/fix-test.patch b/pkgs/tools/misc/nanoemoji/fix-test.patch new file mode 100644 index 000000000000..4582df9ea5b8 --- /dev/null +++ b/pkgs/tools/misc/nanoemoji/fix-test.patch @@ -0,0 +1,24 @@ +--- a/tests/proportional_cbdt.ttx ++++ b/tests/proportional_cbdt.ttx +@@ -13,7 +13,7 @@ + + + +- ++ + + + +@@ -79,10 +79,10 @@ + + + +- ++ + + +- ++ + + + diff --git a/pkgs/tools/misc/nanoemoji/test-pythonpath.patch b/pkgs/tools/misc/nanoemoji/test-pythonpath.patch new file mode 100644 index 000000000000..12733224560c --- /dev/null +++ b/pkgs/tools/misc/nanoemoji/test-pythonpath.patch @@ -0,0 +1,14 @@ +--- a/tests/test_helper.py ++++ b/tests/test_helper.py +@@ -269,9 +269,9 @@ + print("subprocess:", " ".join(cmd)) # very useful on failure + env = { + # We may need to find nanoemoji and other pip-installed cli tools +- "PATH": str(Path(shutil.which("nanoemoji")).parent), ++ "PATH": str(Path(shutil.which("nanoemoji")).parent) + ":" + os.environ["PATH"], + # We may need to find test modules +- "PYTHONPATH": os.pathsep.join((str(Path(__file__).parent),)), ++ "PYTHONPATH": os.pathsep.join((str(Path(__file__).parent),)) + ":" + os.environ["PYTHONPATH"], + } + # Needed for windows CI to function; ref https://github.com/appveyor/ci/issues/1995 + if "SYSTEMROOT" in os.environ: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cc3904692e41..e52631f4bd61 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9727,6 +9727,8 @@ with pkgs; pythonPackages = python3Packages; }; + nanoemoji = python3Packages.callPackage ../tools/misc/nanoemoji { }; + nagelfar = callPackage ../development/tools/nagelfar { }; nats-top = callPackage ../tools/system/nats-top { };