Skip to content

Commit

Permalink
lib: remove top-level with lib
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada authored and rycee committed Oct 31, 2021
1 parent 71902bc commit 3ccddfc
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions modules/lib/dag.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

{ lib }:

with lib;

rec {
let inherit (lib) all any filterAttrs mapAttrs mapAttrsToList toposort;
in rec {

emptyDag = { };

Expand Down
5 changes: 3 additions & 2 deletions modules/lib/file-type.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions modules/lib/gvariant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

{ lib }:

with lib;

let
inherit (lib)
concatMapStringsSep concatStrings escape hasPrefix head replaceStrings;

mkPrimitive = t: v: {
_type = "gvariant";
Expand Down
7 changes: 4 additions & 3 deletions modules/lib/strings.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions modules/lib/types-dag.nix
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
6 changes: 4 additions & 2 deletions modules/lib/types.nix
Original file line number Diff line number Diff line change
@@ -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; };

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/types/dag-merge.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{ config, lib, pkgs, ... }:

with lib;

let
inherit (lib) concatStringsSep hm mkMerge mkOption types;

dag = lib.hm.dag;

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/types/dag-submodule.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{ config, lib, pkgs, ... }:

with lib;

let
inherit (lib) concatStringsSep hm mkOption types;

dag = lib.hm.dag;

Expand Down
5 changes: 1 addition & 4 deletions tests/lib/types/gvariant-merge.nix
Original file line number Diff line number Diff line change
@@ -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; };

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/types/list-or-dag-merge.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{ config, lib, pkgs, ... }:

with lib;

let
inherit (lib) concatStringsSep hm mkMerge mkOption types;

dag = lib.hm.dag;

Expand Down

0 comments on commit 3ccddfc

Please sign in to comment.