add custom nerdfont package

This commit is contained in:
Sean Buckley 2021-12-28 20:56:11 -05:00
parent 497dd7036f
commit 16cd165ae6
3 changed files with 59 additions and 7 deletions

View file

@ -8,13 +8,7 @@ with lib;
security-tools = true;
};
fonts.fonts = [
# vscode: "DejaVuSansMono Nerd Font" (size 16)
# gnome-terminal: "DejaVu Sans Mono, Inconsolata for Powerline Medium 12"
# gnome-terminal setting (dconf): /org/gnome/terminal/legacy/profiles/.../font
pkgs.powerline-fonts
(pkgs.nerdfonts.override { fonts = [ "DejaVuSansMono" ]; })
];
fonts.fonts = [ pkgs.bck-nerdfont ];
environment.systemPackages = with pkgs; [
brave

57
pkgs/bck-nerdfont.nix Normal file
View file

@ -0,0 +1,57 @@
{ stdenv
, lib
, dejavu_fonts
, fetchFromGitHub
, python3
, writeScript
}:
let
py = python3.withPackages (p: [ p.fontforge ]);
# Stick a rectangle on the left edge of the
# powerline symbol to avoid anti-aliasing artifacts
postprocess = writeScript "postprocess.py" ''
#!${py}/bin/python
import fontforge, psMat, sys, os
f = fontforge.open(sys.argv[1])
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.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/
'';
}

View file

@ -9,6 +9,7 @@ let
in
rec
{
bck-nerdfont = pkg ./bck-nerdfont.nix { };
binaryninja = pkg ./binary-ninja-personal { };
commander-x16 = pkg ./commander-x16 { };
gef = pkg ./gef { };