diff options
author | aszlig <aszlig@redmoonstudios.org> | 2017-04-23 23:05:42 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2017-04-23 23:08:17 +0200 |
commit | d84890a208614ba305e66ba96f81f7e2fd378c27 (patch) | |
tree | d3ada36d0ec0c89f4e8b446f0502e84902d3cc26 /pkgs/lib | |
parent | 04b7c6074816ed6c3ef63c48668dc23f1e75037b (diff) |
pkgs: Move callPackageScope into pkgs/lib
Now the pkgs/default.nix is a lot more readable because it has only the top-level derivations and the callPackageScope invocations for the corresponding sub-scopes. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs/lib')
-rw-r--r-- | pkgs/lib/call-package-scope.nix | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pkgs/lib/call-package-scope.nix b/pkgs/lib/call-package-scope.nix new file mode 100644 index 00000000..75c19faf --- /dev/null +++ b/pkgs/lib/call-package-scope.nix @@ -0,0 +1,25 @@ +{ pkgs, pkgsi686Linux }: + +fn: let + inherit (builtins) isFunction intersectAttrs functionArgs; + + f = if isFunction fn then fn else import fn; + + autoArgs = pkgs // { + callPackage = pkgs.lib.callPackageWith (pkgs // super); + callPackage_i686 = pkgs.lib.callPackageWith (pkgsi686Linux // super); + }; + args = intersectAttrs (functionArgs f) autoArgs; + + mkOverridable = overrideFun: origArgs: let + superSet = overrideFun origArgs; + overrideWith = newArgs: let + overridden = if isFunction newArgs then newArgs origArgs else newArgs; + in origArgs // overridden; + in superSet // { + override = newArgs: mkOverridable overrideFun (overrideWith newArgs); + }; + + super = mkOverridable f args; + +in pkgs.recurseIntoAttrs super |