summaryrefslogtreecommitdiffstats
path: root/nixos/modules/config/fonts
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/config/fonts')
-rw-r--r--nixos/modules/config/fonts/fontconfig.nix143
-rw-r--r--nixos/modules/config/fonts/fontdir.nix19
-rw-r--r--nixos/modules/config/fonts/ghostscript.nix9
3 files changed, 84 insertions, 87 deletions
diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix
index 9a9ac08eefeb..feb7546b8de8 100644
--- a/nixos/modules/config/fonts/fontconfig.nix
+++ b/nixos/modules/config/fonts/fontconfig.nix
@@ -23,13 +23,10 @@ And do not repeat our mistakes.
*/
{ config, pkgs, lib, ... }:
-
-with lib;
-
let
cfg = config.fonts.fontconfig;
- fcBool = x: "<bool>" + (boolToString x) + "</bool>";
+ fcBool = x: "<bool>" + (lib.boolToString x) + "</bool>";
pkg = pkgs.fontconfig;
# configuration file to read fontconfig cache
@@ -51,11 +48,11 @@ let
<!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
<fontconfig>
<!-- Font directories -->
- ${concatStringsSep "\n" (map (font: "<dir>${font}</dir>") config.fonts.packages)}
- ${optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
+ ${lib.concatStringsSep "\n" (map (font: "<dir>${font}</dir>") config.fonts.packages)}
+ ${lib.optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
<!-- Pre-generated font caches -->
<cachedir>${cache}</cachedir>
- ${optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) ''
+ ${lib.optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) ''
<cachedir>${cache32}</cachedir>
''}
''}
@@ -89,11 +86,11 @@ let
# priority 52
defaultFontsConf =
let genDefault = fonts: name:
- optionalString (fonts != []) ''
+ lib.optionalString (fonts != []) ''
<alias binding="same">
<family>${name}</family>
<prefer>
- ${concatStringsSep ""
+ ${lib.concatStringsSep ""
(map (font: ''
<family>${font}</family>
'') fonts)}
@@ -125,7 +122,7 @@ let
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
- ${optionalString (!cfg.allowBitmaps) ''
+ ${lib.optionalString (!cfg.allowBitmaps) ''
<!-- Reject bitmap fonts -->
<selectfont>
<rejectfont>
@@ -180,8 +177,14 @@ let
mkdir -p $dst
# fonts.conf
- ln -s ${pkg.out}/etc/fonts/fonts.conf \
+ cp ${pkg.out}/etc/fonts/fonts.conf \
$dst/../fonts.conf
+
+ # horrible sed hack to add the line that was accidentally removed
+ # from the default config in #324516
+ # FIXME: fix that, revert this
+ sed '5i <include ignore_missing="yes">/etc/fonts/conf.d</include>' -i $dst/../fonts.conf
+
# TODO: remove this legacy symlink once people stop using packages built before #95358 was merged
mkdir -p $out/etc/fonts/2.11
ln -s /etc/fonts/fonts.conf \
@@ -191,22 +194,22 @@ let
ln -s ${pkg.out}/etc/fonts/conf.d/*.conf \
$dst/
- ${optionalString (!cfg.antialias)
+ ${lib.optionalString (!cfg.antialias)
(replaceDefaultConfig "10-yes-antialias.conf"
"10-no-antialias.conf")
}
- ${optionalString (cfg.hinting.style != "slight")
+ ${lib.optionalString (cfg.hinting.style != "slight")
(replaceDefaultConfig "10-hinting-slight.conf"
"10-hinting-${cfg.hinting.style}.conf")
}
- ${optionalString (cfg.subpixel.rgba != "none")
+ ${lib.optionalString (cfg.subpixel.rgba != "none")
(replaceDefaultConfig "10-sub-pixel-none.conf"
"10-sub-pixel-${cfg.subpixel.rgba}.conf")
}
- ${optionalString (cfg.subpixel.lcdfilter != "default")
+ ${lib.optionalString (cfg.subpixel.lcdfilter != "default")
(replaceDefaultConfig "11-lcdfilter-default.conf"
"11-lcdfilter-${cfg.subpixel.lcdfilter}.conf")
}
@@ -218,12 +221,12 @@ let
ln -s ${renderConf} $dst/10-nixos-rendering.conf
# 50-user.conf
- ${optionalString (!cfg.includeUserConf) ''
+ ${lib.optionalString (!cfg.includeUserConf) ''
rm $dst/50-user.conf
''}
# local.conf (indirect priority 51)
- ${optionalString (cfg.localConf != "") ''
+ ${lib.optionalString (cfg.localConf != "") ''
ln -s ${localConf} $dst/../local.conf
''}
@@ -233,7 +236,7 @@ let
# 53-no-bitmaps.conf
ln -s ${rejectBitmaps} $dst/53-no-bitmaps.conf
- ${optionalString (!cfg.allowType1) ''
+ ${lib.optionalString (!cfg.allowType1) ''
# 53-nixos-reject-type1.conf
ln -s ${rejectType1} $dst/53-nixos-reject-type1.conf
''}
@@ -251,16 +254,16 @@ let
in
{
imports = [
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowBitmaps" ] [ "fonts" "fontconfig" "allowBitmaps" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowType1" ] [ "fonts" "fontconfig" "allowType1" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "useEmbeddedBitmaps" ] [ "fonts" "fontconfig" "useEmbeddedBitmaps" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "forceAutohint" ] [ "fonts" "fontconfig" "forceAutohint" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "renderMonoTTFAsBitmap" ] [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ])
- (mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "")
- (mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "")
- (mkRemovedOptionModule [ "fonts" "fontconfig" "dpi" ] "Use display server-specific options")
- (mkRemovedOptionModule [ "hardware" "video" "hidpi" "enable" ] fontconfigNote)
- (mkRemovedOptionModule [ "fonts" "optimizeForVeryHighDPI" ] fontconfigNote)
+ (lib.mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowBitmaps" ] [ "fonts" "fontconfig" "allowBitmaps" ])
+ (lib.mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowType1" ] [ "fonts" "fontconfig" "allowType1" ])
+ (lib.mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "useEmbeddedBitmaps" ] [ "fonts" "fontconfig" "useEmbeddedBitmaps" ])
+ (lib.mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "forceAutohint" ] [ "fonts" "fontconfig" "forceAutohint" ])
+ (lib.mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "renderMonoTTFAsBitmap" ] [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ])
+ (lib.mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "")
+ (lib.mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "")
+ (lib.mkRemovedOptionModule [ "fonts" "fontconfig" "dpi" ] "Use display server-specific options")
+ (lib.mkRemovedOptionModule [ "hardware" "video" "hidpi" "enable" ] fontconfigNote)
+ (lib.mkRemovedOptionModule [ "fonts" "optimizeForVeryHighDPI" ] fontconfigNote)
] ++ lib.forEach [ "enable" "substitutions" "preset" ]
(opt: lib.mkRemovedOptionModule [ "fonts" "fontconfig" "ultimate" "${opt}" ] ''
The fonts.fontconfig.ultimate module and configuration is obsolete.
@@ -275,8 +278,8 @@ in
fonts = {
fontconfig = {
- enable = mkOption {
- type = types.bool;
+ enable = lib.mkOption {
+ type = lib.types.bool;
default = true;
description = ''
If enabled, a Fontconfig configuration file will be built
@@ -287,17 +290,17 @@ in
'';
};
- confPackages = mkOption {
+ confPackages = lib.mkOption {
internal = true;
- type = with types; listOf path;
+ type = with lib.types; listOf path;
default = [ ];
description = ''
Fontconfig configuration packages.
'';
};
- antialias = mkOption {
- type = types.bool;
+ antialias = lib.mkOption {
+ type = lib.types.bool;
default = true;
description = ''
Enable font antialiasing. At high resolution (> 200 DPI),
@@ -306,8 +309,8 @@ in
'';
};
- localConf = mkOption {
- type = types.lines;
+ localConf = lib.mkOption {
+ type = lib.types.lines;
default = "";
description = ''
System-wide customization file contents, has higher priority than
@@ -316,8 +319,8 @@ in
};
defaultFonts = {
- monospace = mkOption {
- type = types.listOf types.str;
+ monospace = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
default = ["DejaVu Sans Mono"];
description = ''
System-wide default monospace font(s). Multiple fonts may be
@@ -325,8 +328,8 @@ in
'';
};
- sansSerif = mkOption {
- type = types.listOf types.str;
+ sansSerif = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
default = ["DejaVu Sans"];
description = ''
System-wide default sans serif font(s). Multiple fonts may be
@@ -334,8 +337,8 @@ in
'';
};
- serif = mkOption {
- type = types.listOf types.str;
+ serif = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
default = ["DejaVu Serif"];
description = ''
System-wide default serif font(s). Multiple fonts may be listed
@@ -343,8 +346,8 @@ in
'';
};
- emoji = mkOption {
- type = types.listOf types.str;
+ emoji = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
default = ["Noto Color Emoji"];
description = ''
System-wide default emoji font(s). Multiple fonts may be listed
@@ -360,8 +363,8 @@ in
};
hinting = {
- enable = mkOption {
- type = types.bool;
+ enable = lib.mkOption {
+ type = lib.types.bool;
default = true;
description = ''
Enable font hinting. Hinting aligns glyphs to pixel boundaries to
@@ -371,8 +374,8 @@ in
'';
};
- autohint = mkOption {
- type = types.bool;
+ autohint = lib.mkOption {
+ type = lib.types.bool;
default = false;
description = ''
Enable the autohinter in place of the default interpreter.
@@ -381,8 +384,8 @@ in
'';
};
- style = mkOption {
- type = types.enum ["none" "slight" "medium" "full"];
+ style = lib.mkOption {
+ type = lib.types.enum ["none" "slight" "medium" "full"];
default = "slight";
description = ''
Hintstyle is the amount of font reshaping done to line up
@@ -404,8 +407,8 @@ in
};
};
- includeUserConf = mkOption {
- type = types.bool;
+ includeUserConf = lib.mkOption {
+ type = lib.types.bool;
default = true;
description = ''
Include the user configuration from
@@ -416,9 +419,9 @@ in
subpixel = {
- rgba = mkOption {
+ rgba = lib.mkOption {
default = "none";
- type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"];
+ type = lib.types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"];
description = ''
Subpixel order. The overwhelming majority of displays are
`rgb` in their normal orientation. Select
@@ -432,9 +435,9 @@ in
'';
};
- lcdfilter = mkOption {
+ lcdfilter = lib.mkOption {
default = "default";
- type = types.enum ["none" "default" "light" "legacy"];
+ type = lib.types.enum ["none" "default" "light" "legacy"];
description = ''
FreeType LCD filter. At high resolution (> 200 DPI), LCD filtering
has no visible effect; users of such displays may want to select
@@ -444,16 +447,16 @@ in
};
- cache32Bit = mkOption {
+ cache32Bit = lib.mkOption {
default = false;
- type = types.bool;
+ type = lib.types.bool;
description = ''
Generate system fonts cache for 32-bit applications.
'';
};
- allowBitmaps = mkOption {
- type = types.bool;
+ allowBitmaps = lib.mkOption {
+ type = lib.types.bool;
default = true;
description = ''
Allow bitmap fonts. Set to `false` to ban all
@@ -461,8 +464,8 @@ in
'';
};
- allowType1 = mkOption {
- type = types.bool;
+ allowType1 = lib.mkOption {
+ type = lib.types.bool;
default = false;
description = ''
Allow Type-1 fonts. Default is `false` because of
@@ -470,8 +473,8 @@ in
'';
};
- useEmbeddedBitmaps = mkOption {
- type = types.bool;
+ useEmbeddedBitmaps = lib.mkOption {
+ type = lib.types.bool;
default = false;
description = "Use embedded bitmaps in fonts like Calibri.";
};
@@ -481,8 +484,8 @@ in
};
};
- config = mkMerge [
- (mkIf cfg.enable {
+ config = lib.mkMerge [
+ (lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.fontconfig ];
environment.etc.fonts.source = "${fontconfigEtc}/etc/fonts/";
security.apparmor.includes."abstractions/fonts" = ''
@@ -499,12 +502,12 @@ in
r ${renderConf},
# 50-user.conf
- ${optionalString cfg.includeUserConf ''
+ ${lib.optionalString cfg.includeUserConf ''
r ${pkg.out}/etc/fonts/conf.d.bak/50-user.conf,
''}
# local.conf (indirect priority 51)
- ${optionalString (cfg.localConf != "") ''
+ ${lib.optionalString (cfg.localConf != "") ''
r ${localConf},
''}
@@ -514,13 +517,13 @@ in
# 53-no-bitmaps.conf
r ${rejectBitmaps},
- ${optionalString (!cfg.allowType1) ''
+ ${lib.optionalString (!cfg.allowType1) ''
# 53-nixos-reject-type1.conf
r ${rejectType1},
''}
'';
})
- (mkIf cfg.enable {
+ (lib.mkIf cfg.enable {
fonts.fontconfig.confPackages = [ confPkg ];
})
];
diff --git a/nixos/modules/config/fonts/fontdir.nix b/nixos/modules/config/fonts/fontdir.nix
index 7b21fe30f607..0181883d6c5c 100644
--- a/nixos/modules/config/fonts/fontdir.nix
+++ b/nixos/modules/config/fonts/fontdir.nix
@@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
-
-with lib;
-
let
cfg = config.fonts.fontDir;
@@ -12,7 +9,7 @@ let
find ${toString config.fonts.packages} -regex "$font_regexp" \
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
cd "$out/share/X11/fonts"
- ${optionalString cfg.decompressFonts ''
+ ${lib.optionalString cfg.decompressFonts ''
${pkgs.gzip}/bin/gunzip -f *.gz
''}
${pkgs.xorg.mkfontscale}/bin/mkfontscale
@@ -27,8 +24,8 @@ in
options = {
fonts.fontDir = {
- enable = mkOption {
- type = types.bool;
+ enable = lib.mkOption {
+ type = lib.types.bool;
default = false;
description = ''
Whether to create a directory with links to all fonts in
@@ -36,10 +33,10 @@ in
'';
};
- decompressFonts = mkOption {
- type = types.bool;
+ decompressFonts = lib.mkOption {
+ type = lib.types.bool;
default = config.programs.xwayland.enable;
- defaultText = literalExpression "config.programs.xwayland.enable";
+ defaultText = lib.literalExpression "config.programs.xwayland.enable";
description = ''
Whether to decompress fonts in
{file}`/run/current-system/sw/share/X11/fonts`.
@@ -49,7 +46,7 @@ in
};
};
- config = mkIf cfg.enable {
+ config = lib.mkIf cfg.enable {
environment.systemPackages = [ x11Fonts ];
environment.pathsToLink = [ "/share/X11/fonts" ];
@@ -61,7 +58,7 @@ in
};
imports = [
- (mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
+ (lib.mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
];
}
diff --git a/nixos/modules/config/fonts/ghostscript.nix b/nixos/modules/config/fonts/ghostscript.nix
index 5db7c0ac7179..dd28c72bba76 100644
--- a/nixos/modules/config/fonts/ghostscript.nix
+++ b/nixos/modules/config/fonts/ghostscript.nix
@@ -1,11 +1,8 @@
{ config, lib, pkgs, ... }:
-
-with lib;
-
{
options = {
- fonts.enableGhostscriptFonts = mkOption {
- type = types.bool;
+ fonts.enableGhostscriptFonts = lib.mkOption {
+ type = lib.types.bool;
default = false;
description = ''
Whether to add the fonts provided by Ghostscript (such as
@@ -17,7 +14,7 @@ with lib;
};
- config = mkIf config.fonts.enableGhostscriptFonts {
+ config = lib.mkIf config.fonts.enableGhostscriptFonts {
fonts.packages = [ pkgs.ghostscript.fonts ];
};
}