fontconfig: leverage lib.genAttrs and use mkOrder (#1718)

Link: https://github.com/nix-community/stylix/pull/1718

Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: awwpotato <awwpotato@voidq.com>
Reviewed-by: Flameopathic <64027365+Flameopathic@users.noreply.github.com>
This commit is contained in:
NAHO 2025-08-19 22:46:15 +02:00 committed by GitHub
commit 2567b92466
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 25 additions and 7 deletions

View file

@ -1,16 +1,17 @@
{ mkTarget }:
{ lib, ... }:
mkTarget {
name = "fontconfig";
humanName = "Fontconfig";
configElements =
{ fonts }:
{ listTargetIndex, fonts }:
{
fonts.fontconfig.defaultFonts = {
monospace = [ fonts.monospace.name ];
serif = [ fonts.serif.name ];
sansSerif = [ fonts.sansSerif.name ];
emoji = [ fonts.emoji.name ];
};
fonts.fontconfig.defaultFonts = lib.genAttrs [
"monospace"
"serif"
"sansSerif"
"emoji"
] (family: lib.mkOrder listTargetIndex [ fonts.${family}.name ]);
};
}

View file

@ -17,6 +17,7 @@ in
../target.nix
../release.nix
../overlays.nix
../ordering.nix
] ++ autoload;
config.warnings =
lib.mkIf

View file

@ -13,6 +13,7 @@ in
../pixel.nix
../target.nix
../overlays.nix
../ordering.nix
] ++ autoload;
# See https://github.com/nix-community/nix-on-droid/issues/436

View file

@ -20,6 +20,7 @@ in
../target.nix
../release.nix
../overlays.nix
../ordering.nix
] ++ autoload;
config.warnings =
lib.mkIf

View file

@ -20,6 +20,7 @@ in
../target.nix
../release.nix
../overlays.nix
../ordering.nix
] ++ autoload;
config.warnings =
lib.mkIf

13
stylix/ordering.nix Normal file
View file

@ -0,0 +1,13 @@
{ lib, ... }:
{
options.stylix.listTargetIndex = lib.mkOption {
description = ''
The target index at which stylix inserts into lists.
Intended for use as argument to `lib.mkOrder`.
'';
type = lib.types.int;
default = 600;
internal = true;
readOnly = true;
};
}