Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 1 | pkgs_or_lib: |
| 2 | let |
| 3 | is_pkgs = pkgs_or_lib ? lib; |
| 4 | lib = if is_pkgs then pkgs_or_lib.lib else pkgs_or_lib; |
| 5 | utils = lib.pipe ./. [ |
| 6 | (import ./nixFilesInWithName.nix lib) |
| 7 | (builtins.map (file: rec { |
| 8 | name = lib.removeSuffix ".nix" file.name; |
| 9 | func = import file.path; |
| 10 | accepts_pkgs = builtins.hasAttr "pkgs" (builtins.functionArgs func); |
| 11 | value = |
| 12 | if accepts_pkgs then |
| 13 | func |
| 14 | (builtins.intersectAttrs (builtins.functionArgs func) { |
| 15 | inherit |
| 16 | lib utils; pkgs = pkgs_or_lib; |
| 17 | }) |
| 18 | else if is_pkgs |
| 19 | then func lib |
| 20 | else |
| 21 | func pkgs_or_lib; |
| 22 | include = file.name != "default.nix" && (!accepts_pkgs || is_pkgs); |
| 23 | })) |
| 24 | (builtins.filter (utility: utility.include)) |
| 25 | builtins.listToAttrs |
| 26 | ]; |
| 27 | in utils |