mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
Nixify font scripts
This commit is contained in:
parent
003837a634
commit
d2f90c3b75
71
flake.nix
71
flake.nix
@ -25,6 +25,57 @@
|
||||
# Python with required packages for build scripts
|
||||
pythonEnv = pkgs.python3.withPackages (ps: [ ps.pip ]);
|
||||
|
||||
# Python environment for fontconvert script
|
||||
fontconvertPython = pkgs.python3.withPackages (ps: [ ps.freetype-py ]);
|
||||
|
||||
# Wrapper script for fontconvert.py
|
||||
fontconvertScript = pkgs.writeShellScriptBin "fontconvert" ''
|
||||
exec ${fontconvertPython}/bin/python3 ${./lib/EpdFont/scripts/fontconvert.py} "$@"
|
||||
'';
|
||||
|
||||
# Script to convert all builtin fonts
|
||||
convertBuiltinFontsScript = pkgs.writeShellScriptBin "convert-builtin-fonts" ''
|
||||
set -e
|
||||
if [ ! -d "lib/EpdFont/scripts" ]; then
|
||||
echo "Error: must be run from the project root (where platformio.ini is)"
|
||||
exit 1
|
||||
fi
|
||||
export PATH="${fontconvertPython}/bin:$PATH"
|
||||
cd lib/EpdFont/scripts
|
||||
exec ${pkgs.bash}/bin/bash ./convert-builtin-fonts.sh
|
||||
'';
|
||||
|
||||
# Script to build font IDs (requires Ruby for SHA256 hashing)
|
||||
buildFontIdsScript = pkgs.writeShellScriptBin "build-font-ids" ''
|
||||
set -e
|
||||
if [ ! -d "lib/EpdFont/scripts" ]; then
|
||||
echo "Error: must be run from the project root (where platformio.ini is)"
|
||||
exit 1
|
||||
fi
|
||||
export PATH="${pkgs.ruby}/bin:$PATH"
|
||||
cd lib/EpdFont/scripts
|
||||
exec ${pkgs.bash}/bin/bash ./build-font-ids.sh "$@"
|
||||
'';
|
||||
|
||||
# Combined script to regenerate all fonts (run after editing fontconvert.py)
|
||||
regenerateFontsScript = pkgs.writeShellScriptBin "regenerate-fonts" ''
|
||||
set -e
|
||||
if [ ! -d "lib/EpdFont/scripts" ]; then
|
||||
echo "Error: must be run from the project root (where platformio.ini is)"
|
||||
exit 1
|
||||
fi
|
||||
export PATH="${fontconvertPython}/bin:${pkgs.ruby}/bin:$PATH"
|
||||
echo "Regenerating all builtin fonts..."
|
||||
cd lib/EpdFont/scripts
|
||||
${pkgs.bash}/bin/bash ./convert-builtin-fonts.sh
|
||||
echo ""
|
||||
echo "Building font IDs..."
|
||||
${pkgs.bash}/bin/bash ./build-font-ids.sh > ../builtinFonts/font_ids.h
|
||||
echo "Generated lib/EpdFont/builtinFonts/font_ids.h"
|
||||
echo ""
|
||||
echo "Done! All fonts regenerated."
|
||||
'';
|
||||
|
||||
# FHS environment to run PlatformIO with dynamically linked toolchains
|
||||
fhsEnv = pkgs.buildFHSEnv {
|
||||
name = "pio-env";
|
||||
@ -115,6 +166,26 @@
|
||||
type = "app";
|
||||
program = "${buildScript}/bin/build-firmware";
|
||||
};
|
||||
|
||||
apps.fontconvert = {
|
||||
type = "app";
|
||||
program = "${fontconvertScript}/bin/fontconvert";
|
||||
};
|
||||
|
||||
apps.convert-builtin-fonts = {
|
||||
type = "app";
|
||||
program = "${convertBuiltinFontsScript}/bin/convert-builtin-fonts";
|
||||
};
|
||||
|
||||
apps.build-font-ids = {
|
||||
type = "app";
|
||||
program = "${buildFontIdsScript}/bin/build-font-ids";
|
||||
};
|
||||
|
||||
apps.regenerate-fonts = {
|
||||
type = "app";
|
||||
program = "${regenerateFontsScript}/bin/regenerate-fonts";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user