From 7c7e3d18102790f24bec27175481696eae4baa50 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:47 +0200 Subject: [PATCH] nixos/fonts.fontconfig: remove `with lib;` --- nixos/modules/config/fonts/fontconfig.nix | 135 +++++++++++----------- 1 file changed, 66 insertions(+), 69 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 9a9ac08eefeb..7b58d3adc22b 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) '' @@ -191,22 +188,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 +215,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 +230,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 +248,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 +272,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 +284,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 +303,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 +313,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 +322,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 +331,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 +340,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 +357,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 +368,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 +378,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 +401,8 @@ in }; }; - includeUserConf = mkOption { - type = types.bool; + includeUserConf = lib.mkOption { + type = lib.types.bool; default = true; description = '' Include the user configuration from @@ -416,9 +413,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 +429,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 +441,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 +458,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 +467,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 +478,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 +496,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 +511,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 ]; }) ];