Fix Nix FHS text fonts and fontconfig aliases (#113)

This commit is contained in:
Kalah authored and GitHub committed 2026-10-20 12:14:32 +02:00
1 parent 913dd74a09
commit e727049d67
3 files changed
+73 -1

No files matched your search

+6
View File
@@ -3,6 +3,12 @@ on: [push, pull_request]
permissions:
contents: read
jobs:
nix-fonts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@3c6342b75005b9cc7c7d4069c3e9179247c89012 # v31
- run: nix build .#checks.x86_64-linux.fonts --no-link -L
validate:
runs-on: ubuntu-latest
steps:
+21
View File
@@ -207,6 +207,27 @@ If you start Darling manually in this shell, run `darling shutdown` there
before exiting. A separately launched shell cannot reconnect to an existing
Darling namespace; `darling-lol --stop` can still stop it.
### Text fonts
The FHS environment bundles Liberation and DejaVu text fonts and uses its own
fontconfig configuration and standard aliases. It does not depend on fonts in
the host's `/usr/share/fonts`, which the FHS environment replaces. Fonts in your
user font directories remain available. This also prevents an icon-only user
font inventory from becoming the only fallback for ordinary text.
To check font availability without starting Darling or Riot:
```sh
nix run .#default -- fc-match sans-serif
nix run .#default -- fc-match Arial
```
These should select DejaVu Sans and Liberation Sans respectively. The standalone
`nix build .#checks.x86_64-linux.fonts` check verifies generic and common Windows
font aliases with both an empty home directory and icon-only user fonts. This
checks font availability; CAPTCHA text rendering still needs manual verification
in Riot's UI.
## Files and operational limits
- Workspace: `${XDG_DATA_HOME:-$HOME/.local/share}/darling-lol`.
+46 -1
View File
@@ -12,6 +12,14 @@
pkgs = nixpkgs.legacyPackages.${system};
llvmPackages = pkgs.llvmPackages_21;
# Host /etc/fonts survives buildFHSEnv, but host /usr/share/fonts does
# not. Use store paths for both text fonts and the standard alias rules.
darlingFonts = [ pkgs.liberation_ttf pkgs.dejavu_fonts ];
darlingFontsConf = pkgs.makeFontsConf {
fontDirectories = darlingFonts;
includes = [ "${pkgs.fontconfig.out}/etc/fonts/conf.d" ];
};
# Python environment with dependencies required by tooling
pythonEnv = pkgs.python3.withPackages (
ps: with ps; [
@@ -155,6 +163,8 @@
export DPREFIX="''${DPREFIX:-$HOME/.darling}"
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export FONTCONFIG_FILE=${darlingFontsConf}
export FONTCONFIG_PATH=${pkgs.fontconfig.out}/etc/fonts
export DARLING_RUNNER_DIR=${darlingRunner}/bin
export PATH="$DARLING_RUNNER_DIR:/usr/local/bin:''${PATH:-}"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:''${PKG_CONFIG_PATH:-}"
@@ -253,7 +263,41 @@ DESKTOP_EOF
};
in
{
checks.${system}.packaging = pkgs.runCommand "darling-lol-packaging-tests" {
checks.${system} = {
fonts = pkgs.runCommand "darling-lol-font-tests" {
nativeBuildInputs = [ pkgs.fontconfig ];
} ''
export HOME="$TMPDIR/home" XDG_CONFIG_HOME="$TMPDIR/config"
export XDG_DATA_HOME="$TMPDIR/data" XDG_CACHE_HOME="$TMPDIR/cache"
export FONTCONFIG_FILE=${darlingFontsConf}
export FONTCONFIG_PATH=${pkgs.fontconfig.out}/etc/fonts
mkdir -p "$HOME" "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME"
# Check real font selection with no host or user text fonts available.
check_font() {
actual=$(fc-match --format '%{family}' "$1")
if [ "$actual" != "$2" ]; then
echo "Font match for $1: expected $2, got $actual" >&2
exit 1
fi
test -r "$(fc-match --format '%{file}' "$1")"
}
check_aliases() {
check_font sans-serif 'DejaVu Sans'
check_font serif 'DejaVu Serif'
check_font monospace 'DejaVu Sans Mono'
check_font Arial 'Liberation Sans'
check_font 'Times New Roman' 'Liberation Serif'
check_font 'Courier New' 'Liberation Mono'
}
check_aliases
# Reproduce an icon-only user inventory without host text fonts.
cp -R ${pkgs.font-awesome}/share/fonts "$XDG_DATA_HOME/fonts"
fc-list --format '%{file}\n' | grep -F "$XDG_DATA_HOME/fonts/"
check_aliases
touch "$out"
'';
packaging = pkgs.runCommand "darling-lol-packaging-tests" {
nativeBuildInputs = [ pythonEnv pkgs.bash pkgs.git pkgs.coreutils pkgs.util-linux pkgs.gawk ];
} ''
cp -R ${darlingLol}/share/darling-lol source
@@ -267,6 +311,7 @@ DESKTOP_EOF
grep -q '^Terminal=true$' ${darlingLol}/share/applications/darling-lol.desktop
touch "$out"
'';
};
packages.${system} = {
darling-lol = darlingLol;