mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
Dont build nerdfonts from source
This commit is contained in:
parent
7af7b3effe
commit
855c469a4f
1 changed files with 12 additions and 35 deletions
|
@ -1,14 +1,14 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, dejavu_fonts
|
||||
, fetchFromGitHub
|
||||
{ nerdfonts
|
||||
, python3
|
||||
, runCommand
|
||||
, writeScript
|
||||
}:
|
||||
|
||||
let
|
||||
py = python3.withPackages (p: [ p.fontforge ]);
|
||||
|
||||
src = nerdfonts.override { fonts = [ "DejaVuSansMono" ]; };
|
||||
|
||||
# Stick a rectangle on the left edge of the
|
||||
# powerline symbol to avoid anti-aliasing artifacts
|
||||
postprocess = writeScript "postprocess.py" ''
|
||||
|
@ -18,40 +18,17 @@ let
|
|||
glyph = f[0xE0B0]
|
||||
bb = glyph.boundingBox()
|
||||
pen = glyph.glyphPen(replace=False)
|
||||
pen.moveTo(bb[0],bb[1])
|
||||
pen.lineTo(bb[0],bb[3])
|
||||
pen.lineTo(bb[0]-150,bb[3])
|
||||
pen.lineTo(bb[0]-150,bb[1])
|
||||
pen.moveTo(0, bb[1])
|
||||
pen.lineTo(0, bb[3])
|
||||
pen.lineTo(-150, bb[3])
|
||||
pen.lineTo(-150, bb[1])
|
||||
pen.closePath()
|
||||
os.unlink(sys.argv[1])
|
||||
f.generate(sys.argv[1])
|
||||
'';
|
||||
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "bck-nerdfont";
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ryanoasis";
|
||||
repo = "nerd-fonts";
|
||||
rev = "v2.1.0";
|
||||
sha256 = "j0cLZHOLyoItdvLOQVQVurY3ARtndv0FZTynaYJPR9E=";
|
||||
};
|
||||
|
||||
buildPhase = ''
|
||||
# Either Octicons or FontAwesome are required. Take your pick.
|
||||
# They cause the fontlinux characters to move to the correct slots.
|
||||
# (see fontlinuxExactEncodingPosition)
|
||||
find ${dejavu_fonts}/share/fonts/truetype -name 'DejaVuSansMono*' -print0 |
|
||||
xargs -0n1 ${py}/bin/python $src/font-patcher \
|
||||
--fontlinux --octicons --powerline \
|
||||
--postprocess ${postprocess}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/fonts/truetype
|
||||
cp -v *.ttf $out/share/fonts/truetype/
|
||||
'';
|
||||
}
|
||||
runCommand "bck-nerdfont" { inherit src; } ''
|
||||
find $src -name '*Complete.ttf' -exec install -D -t $out/share/fonts/truetype {} \;
|
||||
find $out -name '*Complete.ttf' -exec ${postprocess} {} \;
|
||||
''
|
||||
|
|
Loading…
Reference in a new issue