From fa695d885eb613113e9f95c3799948d3cbfb0c44 Mon Sep 17 00:00:00 2001 From: avosirenfal Date: Mon, 25 May 2026 18:49:59 -0700 Subject: [PATCH 1/3] nixos/fontconfig: add alias support --- nixos/modules/config/fonts/fontconfig.nix | 101 ++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 62214cacc101..74a931e8b0c5 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -127,6 +127,38 @@ let ''; + # user defined font aliases + # priority 53 + aliases = + let + mkFontBlock = + key: fonts: + lib.optionalString ((builtins.length fonts) > 0) '' + <${key}> + ${lib.concatStringsSep "" (map (font: "${font}") fonts)} + + ''; + + mkAliasBlock = family: opts: '' + + ${family} + ${mkFontBlock "prefer" opts.prefer} + ${mkFontBlock "accept" opts.accept} + ${mkFontBlock "default" opts.default} + + ''; + in + pkgs.writeText "fc-53-user-aliases.conf" '' + + + + + + ${lib.concatStringsSep "" (lib.mapAttrsToList mkAliasBlock cfg.aliases)} + + + ''; + # bitmap font options # priority 53 rejectBitmaps = pkgs.writeText "fc-53-no-bitmaps.conf" '' @@ -245,6 +277,9 @@ let # 53-no-bitmaps.conf ln -s ${rejectBitmaps} $dst/53-no-bitmaps.conf + # 53-user-aliases.conf + ln -s ${aliases} $dst/53-user-aliases.conf + ${lib.optionalString (!cfg.allowType1) '' # 53-nixos-reject-type1.conf ln -s ${rejectType1} $dst/53-nixos-reject-type1.conf @@ -522,6 +557,69 @@ in description = "Use embedded bitmaps in fonts like Calibri."; }; + aliases = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.submodule { + options = { + binding = lib.mkOption { + type = lib.types.enum [ + "same" + "weak" + "strong" + ]; + default = "same"; + description = '' + Binding precedence for this font family. See + fontconfig "Font Matching" section for details. + ''; + }; + + prefer = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = '' + Fonts whose glyphs are chosen preferentially prior + to fonts which match the alias family. + ''; + }; + + accept = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = '' + Fonts that are chosen if none of the preferred + fonts, nor the alias family could provide the + desired glyph. + ''; + }; + + default = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = '' + Last chance fallback fonts which are chosen by + default if none of the other options could + provide the desired glyph. + ''; + }; + }; + } + ); + default = { }; + example = lib.literalExpression '' + { + # use FreeSans for Greek symbols missing in Helvetica + "Helvetica" = { + default = [ "FreeSans" ]; + }; + }; + ''; + description = '' + Font aliases that can substitute preferential fonts, + or specify custom fallback fonts. + ''; + }; + }; }; @@ -557,6 +655,9 @@ in # 52-nixos-default-fonts.conf r ${defaultFontsConf}, + # 53-user-aliases.conf + r ${aliases}, + # 53-no-bitmaps.conf r ${rejectBitmaps}, From 134e32b7c7111ad9210db13c794beaf010723d82 Mon Sep 17 00:00:00 2001 From: Siren Date: Sat, 13 Jun 2026 16:00:28 -0700 Subject: [PATCH 2/3] nixos/fontconfig: concatStringsSep -> concatMapStrings Co-authored-by: gabby --- nixos/modules/config/fonts/fontconfig.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 74a931e8b0c5..861b17cc96a2 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -135,7 +135,7 @@ let key: fonts: lib.optionalString ((builtins.length fonts) > 0) '' <${key}> - ${lib.concatStringsSep "" (map (font: "${font}") fonts)} + ${lib.concatMapStrings (font: "${font}") fonts} ''; From b87e5beca208dc5c7f7f20d1090c6acb63c701d4 Mon Sep 17 00:00:00 2001 From: Siren Date: Sat, 13 Jun 2026 16:01:01 -0700 Subject: [PATCH 3/3] nixos/fontconfig: concatStringsSep -> concatStrings Co-authored-by: gabby --- nixos/modules/config/fonts/fontconfig.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 861b17cc96a2..16b22841ac14 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -154,7 +154,7 @@ let - ${lib.concatStringsSep "" (lib.mapAttrsToList mkAliasBlock cfg.aliases)} + ${lib.concatStrings (lib.mapAttrsToList mkAliasBlock cfg.aliases)} '';