diff --git a/nib/default.nix b/nib/default.nix index e786ef4..0a7507f 100644 --- a/nib/default.nix +++ b/nib/default.nix @@ -1,26 +1,48 @@ {systems, ...}: let - std = import ./std; + std = import ./std {}; + parse = import ./parse { + attrs = std.attrs; + result = std.result; + }; in - std - // { - # === External Functions === - withPkgs = repo: config: system: - import repo { - inherit system; - } - // config; + builtins.listToAttrs [ + # submodule content is accessible first by submodule name + # then by the name of the content (ie self.submodule.myFunc) + {inherit parse;} - mkSys = input: { - forAllSystems = f: - std.genAttrs systems ( - system: f system input.pkgs - ); - }; + # submodule is included directly to this module (ie self.myFunc) + std - mkUSys = input: { - forAllSystems = f: - std.genAttrs systems ( - system: f system input.pkgs input.upkgs - ); - }; - } + # this module + { + # === External Functions === + withPkgs = repo: config: system: + import repo { + inherit system; + } + // config; + + mkSys = input: let + # function taking a system as argument + pkgsFor = input.pkgs; + in { + inherit pkgsFor; + forAllSystems = f: + std.genAttrs systems ( + system: f system (pkgsFor system) + ); + }; + + mkUSys = input: let + # functions taking a system as argument + pkgsFor = input.pkgs; + upkgsFor = input.upkgs; + in { + inherit pkgsFor upkgsFor; + forAllSystems = f: + std.genAttrs systems ( + system: f system (pkgsFor system) (upkgsFor system) + ); + }; + } + ]