From 8a034c526ef48e395727c825041fe328e98416f8 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Tue, 5 Mar 2024 17:42:18 -0800 Subject: [PATCH] Avoid `with lib;` at the top level in pkgs/top-level/config.nix --- pkgs/top-level/config.nix | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pkgs/top-level/config.nix b/pkgs/top-level/config.nix index aa3a235553ef..3418a44e0f13 100644 --- a/pkgs/top-level/config.nix +++ b/pkgs/top-level/config.nix @@ -2,14 +2,20 @@ { config, lib, ... }: -with lib; - let + inherit (lib) + literalExpression + mapAttrsToList + mdDoc + mkOption + optionals + types + ; mkMassRebuild = args: mkOption (builtins.removeAttrs args [ "feature" ] // { type = args.type or (types.uniq types.bool); default = args.default or false; - description = lib.mdDoc ((args.description or '' + description = mdDoc ((args.description or '' Whether to ${args.feature} while building nixpkgs packages. '') + '' Changing the default may cause a mass rebuild. @@ -34,7 +40,7 @@ let /* Config options */ warnUndeclaredOptions = mkOption { - description = lib.mdDoc "Whether to warn when `config` contains an unrecognized attribute."; + description = mdDoc "Whether to warn when `config` contains an unrecognized attribute."; type = types.bool; default = false; }; @@ -66,7 +72,7 @@ let allowAliases = mkOption { type = types.bool; default = true; - description = lib.mdDoc '' + description = mdDoc '' Whether to expose old attribute names for compatibility. The recommended setting is to enable this, as it @@ -86,7 +92,7 @@ let default = false; # getEnv part is in check-meta.nix defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1"''; - description = lib.mdDoc '' + description = mdDoc '' Whether to allow unfree packages. See [Installing unfree packages](https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree) in the NixOS manual. @@ -98,7 +104,7 @@ let default = false; # getEnv part is in check-meta.nix defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1"''; - description = lib.mdDoc '' + description = mdDoc '' Whether to allow broken packages. See [Installing broken packages](https://nixos.org/manual/nixpkgs/stable/#sec-allow-broken) in the NixOS manual. @@ -110,7 +116,7 @@ let default = false; # getEnv part is in check-meta.nix defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1"''; - description = lib.mdDoc '' + description = mdDoc '' Whether to allow unsupported packages. See [Installing packages on unsupported systems](https://nixos.org/manual/nixpkgs/stable/#sec-allow-unsupported-system) in the NixOS manual. @@ -132,7 +138,7 @@ let showDerivationWarnings = mkOption { type = types.listOf (types.enum [ "maintainerless" ]); default = []; - description = lib.mdDoc '' + description = mdDoc '' Which warnings to display for potentially dangerous or deprecated values passed into `stdenv.mkDerivation`. @@ -147,7 +153,7 @@ let checkMeta = mkOption { type = types.bool; default = false; - description = lib.mdDoc '' + description = mdDoc '' Whether to check that the `meta` attribute of derivations are correct during evaluation time. ''; }; @@ -156,7 +162,7 @@ let in { freeformType = - let t = lib.types.lazyAttrsOf lib.types.raw; + let t = types.lazyAttrsOf types.raw; in t // { merge = loc: defs: let r = t.merge loc defs; @@ -166,8 +172,8 @@ in { inherit options; config = { - warnings = lib.optionals config.warnUndeclaredOptions ( - lib.mapAttrsToList (k: v: "undeclared Nixpkgs option set: config.${k}") config._undeclared or {} + warnings = optionals config.warnUndeclaredOptions ( + mapAttrsToList (k: v: "undeclared Nixpkgs option set: config.${k}") config._undeclared or {} ); };