I am trying to convert the terminal font I use, FiraCode Nerd Font, into a .psf file using pkgs.RunCommand
so I can set it as my TTY font. However, the derivations fails with the log only having the message Fontconfig error: no writable cache directories
repeated a handful of times.
Below is what I have so far. Note that I’m using Stylix’s font settings to specify the font to use. I assume the first line of runCommand
, the line with fc-match
, is the one failing with an error.
console.font =
let
font = config.stylix.fonts.monospace;
in
pkgs.runCommand "${font.package.name}.psf"
{
FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [ font.package ]; };
} ''
# Use fontconfig to select the correct .ttf or .otf file based on name
font=$(${pkgs.fontconfig}/bin/fc-match -v ${font.name} | grep "file:" | cut -d '"' -f 2)
# Convert to bdf
bdfFont=$(mktemp)
${pkgs.otf2bdf}/bin/otf2bdf -r 72 -p 16 -c C $font |
sed -e "s/AVERAGE_WIDTH.*/AVERAGE_WIDTH 80/" > $bdfFont
# Convert to psf
${pkgs.bdf2psf}/bin/bdf2psf $bdfFont ${pkgs.bdf2psf}/share/bdf2psf/standard.equivalents \
${pkgs.bdf2psf}/share/bdf2psf/linux.set+${pkgs.bdf2psf}/share/bdf2psf/useful.set} 256 $out
'';