This commit is contained in:
Daniel Flanagan 2024-02-02 15:28:57 -06:00
parent cf89dc9e8b
commit 69b372d036
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
6 changed files with 78 additions and 5 deletions

View file

@ -58,7 +58,7 @@
# Your custom packages
# Acessible through 'nix build', 'nix shell', etc
packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
packages = forAllSystems (system: import ./pkgs {pkgs = nixpkgs.legacyPackages.${system};});
# Formatter for your nix files, available through 'nix fmt'
# Other options beside 'alejandra' include 'nixpkgs-fmt'

View file

@ -1,6 +1,12 @@
# Custom packages, that can be defined similarly to ones from nixpkgs
# You can build them using 'nix build .#example'
{pkgs, ...}: {
iosevka-lyte-term = pkgs.callPackage ./iosevka-lyte-term.nix {inherit pkgs;};
{pkgs, ...}: rec {
iosevka-lyte-term = pkgs.callPackage ./iosevka-lyte-term.nix {inherit (pkgs) iosevka;};
iosevka-lyte-term-min = pkgs.callPackage ./iosevka-lyte-term-min.nix {
inherit pkgs;
inherit (pkgs) brotli;
inherit iosevka-lyte-term;
fonttools = pkgs.python311Packages.fonttools;
};
# example = pkgs.callPackage ./example { };
}

View file

@ -0,0 +1,29 @@
{
pkgs,
fonttools,
brotli,
iosevka-lyte-term,
...
}: let
BASE_FONTS = "${iosevka-lyte-term}/share/fonts/truetype";
in
pkgs.stdenvNoCC.mkDerivation {
inherit BASE_FONTS;
pname = "iosevka-lyte-term-min";
version = iosevka-lyte-term.version;
# do I need to include makesubset.bash and subset-glyphs.txt?
buildInputs = [fonttools brotli];
srcs = [
BASE_FONTS
./makesubset.bash
];
installPhase = ''
mkdir -p "$out/share/fonts/truetype"
for f in "$BASE_FONTS"/dist/iosevkalyteweb/woff2/*.woff2; do
if [[ $f == *".subset.woff2"* ]]; then
pyftsubset "$f" --name-IDs+=0,4,6 --text-file=./subset-glyphs.txt --flavor=woff2 &
fi
done
wait
'';
}

View file

@ -1,6 +1,28 @@
{pkgs, ...}:
pkgs.iosevka.override {
{iosevka, ...}:
(iosevka.overrideAttrs
(final: prev: {
pname = "iosevka-lyte-term";
buildPhase = ''
export HOME=$TMPDIR
runHook preBuild
npm run build --no-update-notifier -- --jCmd=$NIX_BUILD_CORES --verbose=9 ttf::iosevka-lyteterm
npm run build --no-update-notifier -- --jCmd=$NIX_BUILD_CORES --verbose=9 woff2::iosevka-lyteterm
runHook postBuild
'';
installPhase = ''
runHook preInstall
fontdir="$out/share/fonts"
install -d "$fontdir"
install "dist/$pname/ttf"/* "$fontdir/truetype"
install "dist/$pname/woff2"/* "$fontdir/woff2"
runHook postInstall
'';
}))
.override {
set = "lyteterm";
privateBuildPlan = ''
[buildPlans.iosevka-lyteterm]
family = "IosevkaLyteTerm"

15
pkgs/makesubset.bash Normal file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
echo "out: $out"
echo "src: $src"
echo "BASE_FONTS: $BASE_FONTS"
echo "srcs: $srcs"
mkdir -p "$out/share/fonts/truetype"
for f in "$src"/dist/iosevkalyteweb/woff2/*.woff2; do
if [[ $f == *".subset.woff2"* ]]; then
pyftsubset "$f" --name-IDs+=0,4,6 --text-file=./subset-glyphs.txt --flavor=woff2 &
fi
done
wait
mv ./dist/iosevkalyteweb/woff2/*.subset.woff2 ./dist/iosevkalyteweb/woff2-subset/
touch ./dist/iosevkalyteweb/woff2-subset/

1
pkgs/subset-glyphs.txt Normal file
View file

@ -0,0 +1 @@
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ‌… ⎜⎡⎣─│┊└├┬╯░▒♯