1# Logic largely stolen from https://github.com/tgirlcloud/pkgs/blob/6f929dface8c099634067c02e242e0c668c4858b/default.nix
2# Thank you idabell <3
3
4# All configuration is intentionally left provided by the provided nixpkgs instance
5nixpkgs: wrappers: let
6 inherit (builtins) readDir;
7 inherit (nixpkgs) lib;
8 inherit (lib) mapAttrs mergeAttrsList mapAttrsToList;
9
10 baseDirectory = ./pkgs;
11
12 packagesForShard =
13 shard: type:
14 mapAttrs (name: _: baseDirectory + "/${shard}/${name}/package.nix") (
15 readDir (baseDirectory + "/${shard}")
16 );
17
18 packagesFiles = mergeAttrsList (mapAttrsToList packagesForShard (readDir baseDirectory));
19
20 packages = lib.makeScope nixpkgs.newScope (self: {
21 wlib = wrappers.lib;
22 wrappers = lib.mapAttrs (name: wrapper: conf: (wrapper.apply (conf // { pkgs = nixpkgs; })).wrapper) wrappers.wrapperModules;
23 } // (mapAttrs (_: lib.flip self.callPackage { }) packagesFiles));
24in packages
25