From 0657aa5509d0fc5ca79c9e2bf0621f7cc1623694 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sat, 24 Aug 2024 22:05:25 +0200 Subject: [PATCH] nixos/i18n: remove `with lib;` --- nixos/modules/config/i18n.nix | 45 ++++++++++++++++------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/nixos/modules/config/i18n.nix b/nixos/modules/config/i18n.nix index 9d2d3c23beb3..e94186f19d76 100644 --- a/nixos/modules/config/i18n.nix +++ b/nixos/modules/config/i18n.nix @@ -1,26 +1,23 @@ { config, lib, pkgs, ... }: - -with lib; - { ###### interface options = { i18n = { - glibcLocales = mkOption { - type = types.path; + glibcLocales = lib.mkOption { + type = lib.types.path; default = pkgs.glibcLocales.override { - allLocales = any (x: x == "all") config.i18n.supportedLocales; + allLocales = lib.any (x: x == "all") config.i18n.supportedLocales; locales = config.i18n.supportedLocales; }; - defaultText = literalExpression '' + defaultText = lib.literalExpression '' pkgs.glibcLocales.override { allLocales = any (x: x == "all") config.i18n.supportedLocales; locales = config.i18n.supportedLocales; } ''; - example = literalExpression "pkgs.glibcLocales"; + example = lib.literalExpression "pkgs.glibcLocales"; description = '' Customized pkg.glibcLocales package. @@ -29,8 +26,8 @@ with lib; ''; }; - defaultLocale = mkOption { - type = types.str; + defaultLocale = lib.mkOption { + type = lib.types.str; default = "en_US.UTF-8"; example = "nl_NL.UTF-8"; description = '' @@ -40,8 +37,8 @@ with lib; ''; }; - extraLocaleSettings = mkOption { - type = types.attrsOf types.str; + extraLocaleSettings = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = {}; example = { LC_MESSAGES = "en_US.UTF-8"; LC_TIME = "de_DE.UTF-8"; }; description = '' @@ -51,24 +48,24 @@ with lib; ''; }; - supportedLocales = mkOption { - type = types.listOf types.str; - default = unique - (builtins.map (l: (replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") ( + supportedLocales = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = lib.unique + (builtins.map (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") ( [ "C.UTF-8" "en_US.UTF-8" config.i18n.defaultLocale - ] ++ (attrValues (filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings)) + ] ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings)) )); - defaultText = literalExpression '' - unique - (builtins.map (l: (replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") ( + defaultText = lib.literalExpression '' + lib.unique + (builtins.map (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") ( [ "C.UTF-8" "en_US.UTF-8" config.i18n.defaultLocale - ] ++ (attrValues (filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings)) + ] ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings)) )) ''; example = ["en_US.UTF-8/UTF-8" "nl_NL.UTF-8/UTF-8" "nl_NL/ISO-8859-1"]; @@ -91,14 +88,14 @@ with lib; environment.systemPackages = # We increase the priority a little, so that plain glibc in systemPackages can't win. - optional (config.i18n.supportedLocales != []) (lib.setPrio (-1) config.i18n.glibcLocales); + lib.optional (config.i18n.supportedLocales != []) (lib.setPrio (-1) config.i18n.glibcLocales); environment.sessionVariables = { LANG = config.i18n.defaultLocale; LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive"; } // config.i18n.extraLocaleSettings; - systemd.globalEnvironment = mkIf (config.i18n.supportedLocales != []) { + systemd.globalEnvironment = lib.mkIf (config.i18n.supportedLocales != []) { LOCALE_ARCHIVE = "${config.i18n.glibcLocales}/lib/locale/locale-archive"; }; @@ -106,7 +103,7 @@ with lib; environment.etc."locale.conf".source = pkgs.writeText "locale.conf" '' LANG=${config.i18n.defaultLocale} - ${concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${v}") config.i18n.extraLocaleSettings)} + ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n}=${v}") config.i18n.extraLocaleSettings)} ''; };