fontconfig: enable config files by default

This commit makes the `fonts.fontconfig.configFile.<name>.enable` option
true by default which matches the behaviour of `home.file` and the like.
This commit is contained in:
Benedikt Rips
2026-04-26 14:40:00 +02:00
committed by Austin Horstman
parent 07c723c3fe
commit c0436bc028
5 changed files with 80 additions and 30 deletions

View File

@@ -16,11 +16,35 @@ let
inherit (config.home) profileDirectory;
globalConfig = config;
fontConfigFileType = lib.types.submodule (
{ name, ... }:
{
options = {
enable = lib.mkEnableOption "Whether this font config file should be generated.";
enable = lib.mkOption {
description = ''
Whether this file should be generated. This option allows specific
files to be disabled.
'';
type = lib.types.bool;
inherit
(lib.hm.deprecations.mkStateVersionOptionDefault {
inherit (globalConfig.home) stateVersion;
since = "26.11";
optionPath = [
"fonts"
"fontconfig"
"configFile"
name
"enable"
];
legacy.value = false;
current.value = true;
})
default
defaultText
;
};
text = lib.mkOption {
type = lib.types.nullOr lib.types.lines;
default = null;

View File

@@ -6,4 +6,6 @@
fontconfig-default-rendering = ./default-rendering.nix;
fontconfig-custom-rendering = ./custom-rendering.nix;
fontconfig-extra-config-files = ./extra-config-files.nix;
fontconfig-old-default-configFile-toggle = ./old-default-configFile-toggle.nix;
}

View File

@@ -1,33 +1,53 @@
{ lib, ... }:
let
sampleTextContent = "hello world";
fcConfD = "home-files/.config/fontconfig/conf.d";
sampleText = "hello world";
sampleSource = builtins.toFile "fontconfig-source" ''
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
...
</fontconfig>
'';
in
{
home.stateVersion = lib.trivial.release;
fonts.fontconfig = {
enable = true;
configFile = {
text-label-test = {
enable = true;
label = "sample-text-config";
text = sampleTextContent;
priority = 55;
disabled = {
enable = false;
text = "";
};
source-nolabel-test = {
enable = true;
source = ./sample-extra-config.conf;
label = {
label = "custom_label";
text = "";
};
priority = {
priority = 37;
text = "";
};
text.text = sampleText;
source.source = sampleSource;
};
};
nmt.script = ''
assertDirectoryExists ${fcConfD}
assertFileExists ${fcConfD}/55-hm-sample-text-config.conf
assertFileContent ${fcConfD}/55-hm-sample-text-config.conf \
${builtins.toFile "sample-text-config" sampleTextContent}
assertPathNotExists ${fcConfD}/90-hm-disabled.conf
assertFileExists ${fcConfD}/90-hm-source-nolabel-test.conf
assertFileContent ${fcConfD}/90-hm-source-nolabel-test.conf \
${./sample-extra-config.conf}
assertFileExists ${fcConfD}/90-hm-custom_label.conf
assertFileExists ${fcConfD}/37-hm-priority.conf
assertFileExists ${fcConfD}/90-hm-text.conf
assertFileContent ${fcConfD}/90-hm-text.conf \
${builtins.toFile "sample-text-config" sampleText}
assertFileExists ${fcConfD}/90-hm-source.conf
assertFileContent ${fcConfD}/90-hm-source.conf ${sampleSource}
'';
}

View File

@@ -0,0 +1,18 @@
let
fcConfD = "home-files/.config/fontconfig/conf.d";
in
{
home.stateVersion = "26.05"; # <= 26.11
fonts.fontconfig = {
enable = true;
configFile.implicitly-disabled.text = "foo";
};
nmt.script = ''
assertFileExists ${fcConfD}/10-hm-fonts.conf
assertFileExists ${fcConfD}/52-hm-default-fonts.conf
assertPathNotExists ${fcConfD}/90-hm-implicitly-disabled.conf
'';
}

View File

@@ -1,14 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<description>Disable anti-aliasing for Tamzen since it is a bitmap font</description>
<match target="pattern">
<test name="family" compare="eq" qual="any">
<string>Tamzen</string>
</test>
<edit name="antialias" mode="assign">
<bool>false</bool>
</edit>
</match>
</fontconfig>