From 3ccddfc48dde625044f243049a4830a7104d9095 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 27 Oct 2021 08:58:56 -0300 Subject: [PATCH] lib: remove top-level `with lib` --- modules/lib/dag.nix | 5 ++--- modules/lib/file-type.nix | 5 +++-- modules/lib/gvariant.nix | 4 ++-- modules/lib/strings.nix | 7 ++++--- modules/lib/types-dag.nix | 6 ++++-- modules/lib/types.nix | 6 ++++-- tests/lib/types/dag-merge.nix | 3 +-- tests/lib/types/dag-submodule.nix | 3 +-- tests/lib/types/gvariant-merge.nix | 5 +---- tests/lib/types/list-or-dag-merge.nix | 3 +-- 10 files changed, 23 insertions(+), 24 deletions(-) diff --git a/modules/lib/dag.nix b/modules/lib/dag.nix index cbe341296..0c0e33ee7 100644 --- a/modules/lib/dag.nix +++ b/modules/lib/dag.nix @@ -9,9 +9,8 @@ { lib }: -with lib; - -rec { +let inherit (lib) all any filterAttrs mapAttrs mapAttrsToList toposort; +in rec { emptyDag = { }; diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix index 114ef0357..0b30cb1b6 100644 --- a/modules/lib/file-type.nix +++ b/modules/lib/file-type.nix @@ -1,7 +1,8 @@ { homeDirectory, lib, pkgs }: -with lib; - +let + inherit (lib) hasPrefix hm literalExpression mkDefault mkIf mkOption removePrefix types; +in { # Constructs a type suitable for a `home.file` like option. The # target path may be either absolute or relative, in which case it diff --git a/modules/lib/gvariant.nix b/modules/lib/gvariant.nix index 67e41a19b..7c4ca5b08 100644 --- a/modules/lib/gvariant.nix +++ b/modules/lib/gvariant.nix @@ -5,9 +5,9 @@ { lib }: -with lib; - let + inherit (lib) + concatMapStringsSep concatStrings escape hasPrefix head replaceStrings; mkPrimitive = t: v: { _type = "gvariant"; diff --git a/modules/lib/strings.nix b/modules/lib/strings.nix index fe7b2fa30..f59d81508 100644 --- a/modules/lib/strings.nix +++ b/modules/lib/strings.nix @@ -1,8 +1,9 @@ { lib }: -with lib; - -{ +let + inherit (lib) + genList length lowerChars replaceStrings stringToCharacters upperChars; +in { # Figures out a valid Nix store name for the given path. storeFileName = path: let diff --git a/modules/lib/types-dag.nix b/modules/lib/types-dag.nix index 2efb12645..68a5826fe 100644 --- a/modules/lib/types-dag.nix +++ b/modules/lib/types-dag.nix @@ -1,8 +1,10 @@ { dag, lib }: -with lib; - let + inherit (lib) + concatStringsSep defaultFunctor fixedWidthNumber imap1 isAttrs isList length + listToAttrs mapAttrs mkIf mkOption mkOptionType nameValuePair stringLength + types warn; isDagEntry = e: isAttrs e && (e ? data) && (e ? after) && (e ? before); diff --git a/modules/lib/types.nix b/modules/lib/types.nix index a45f43406..71ec587f1 100644 --- a/modules/lib/types.nix +++ b/modules/lib/types.nix @@ -1,9 +1,11 @@ { lib, dag ? import ./dag.nix { inherit lib; } , gvariant ? import ./gvariant.nix { inherit lib; } }: -with lib; - let + inherit (lib) + all concatMap foldl' getFiles getValues head isFunction literalExpression + mergeAttrs mergeDefaultOption mergeOneOption mergeOptions mkOption + mkOptionType showFiles showOption types; typesDag = import ./types-dag.nix { inherit dag lib; }; diff --git a/tests/lib/types/dag-merge.nix b/tests/lib/types/dag-merge.nix index 40214bb45..5e361cd7e 100644 --- a/tests/lib/types/dag-merge.nix +++ b/tests/lib/types/dag-merge.nix @@ -1,8 +1,7 @@ { config, lib, pkgs, ... }: -with lib; - let + inherit (lib) concatStringsSep hm mkMerge mkOption types; dag = lib.hm.dag; diff --git a/tests/lib/types/dag-submodule.nix b/tests/lib/types/dag-submodule.nix index 29819ceb6..809b1a59b 100644 --- a/tests/lib/types/dag-submodule.nix +++ b/tests/lib/types/dag-submodule.nix @@ -1,8 +1,7 @@ { config, lib, pkgs, ... }: -with lib; - let + inherit (lib) concatStringsSep hm mkOption types; dag = lib.hm.dag; diff --git a/tests/lib/types/gvariant-merge.nix b/tests/lib/types/gvariant-merge.nix index d2cdb535e..c4de6827f 100644 --- a/tests/lib/types/gvariant-merge.nix +++ b/tests/lib/types/gvariant-merge.nix @@ -1,9 +1,6 @@ { config, lib, pkgs, ... }: -with lib; - -let - +let inherit (lib) concatStringsSep hm mapAttrsToList mkMerge mkOption types; in { options.examples = mkOption { type = types.attrsOf hm.types.gvariant; }; diff --git a/tests/lib/types/list-or-dag-merge.nix b/tests/lib/types/list-or-dag-merge.nix index 389938774..4706c5ced 100644 --- a/tests/lib/types/list-or-dag-merge.nix +++ b/tests/lib/types/list-or-dag-merge.nix @@ -1,8 +1,7 @@ { config, lib, pkgs, ... }: -with lib; - let + inherit (lib) concatStringsSep hm mkMerge mkOption types; dag = lib.hm.dag;