diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index a44b1fecd29a..98d90ccc0fca 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: "" + (boolToString x) + ""; + fcBool = x: "" + (lib.boolToString x) + ""; pkg = pkgs.fontconfig; # configuration file to read fontconfig cache @@ -51,11 +48,11 @@ let - ${concatStringsSep "\n" (map (font: "${font}") config.fonts.packages)} - ${optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) '' + ${lib.concatStringsSep "\n" (map (font: "${font}") config.fonts.packages)} + ${lib.optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) '' ${cache} - ${optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) '' + ${lib.optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) '' ${cache32} ''} ''} @@ -89,11 +86,11 @@ let # priority 52 defaultFontsConf = let genDefault = fonts: name: - optionalString (fonts != []) '' + lib.optionalString (fonts != []) '' ${name} - ${concatStringsSep "" + ${lib.concatStringsSep "" (map (font: '' ${font} '') fonts)} @@ -125,7 +122,7 @@ let - ${optionalString (!cfg.allowBitmaps) '' + ${lib.optionalString (!cfg.allowBitmaps) '' @@ -197,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") } @@ -224,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 ''} @@ -239,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 ''} @@ -257,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. @@ -281,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 @@ -293,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), @@ -312,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 @@ -322,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 @@ -331,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 @@ -340,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 @@ -349,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 @@ -366,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 @@ -377,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. @@ -387,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 @@ -410,8 +407,8 @@ in }; }; - includeUserConf = mkOption { - type = types.bool; + includeUserConf = lib.mkOption { + type = lib.types.bool; default = true; description = '' Include the user configuration from @@ -422,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 @@ -438,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 @@ -450,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 @@ -467,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 @@ -476,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."; }; @@ -487,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" = '' @@ -505,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}, ''} @@ -520,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 ]; }) ];