# Logic largely stolen from https://github.com/tgirlcloud/pkgs/blob/6f929dface8c099634067c02e242e0c668c4858b/default.nix # Thank you idabell <3 # All configuration is intentionally left provided by the provided nixpkgs instance nixpkgs: wrappers: let inherit (builtins) readDir; inherit (nixpkgs) lib; inherit (lib) mapAttrs mergeAttrsList mapAttrsToList; baseDirectory = ./pkgs; packagesForShard = shard: type: mapAttrs (name: _: baseDirectory + "/${shard}/${name}/package.nix") ( readDir (baseDirectory + "/${shard}") ); packagesFiles = mergeAttrsList (mapAttrsToList packagesForShard (readDir baseDirectory)); packages = lib.makeScope nixpkgs.newScope (self: { wlib = wrappers.lib; wrappers = lib.mapAttrs (name: wrapper: conf: (wrapper.apply (conf // { pkgs = nixpkgs; })).wrapper) wrappers.wrapperModules; } // (mapAttrs (_: lib.flip self.callPackage { }) packagesFiles)); in packages