From d84890a208614ba305e66ba96f81f7e2fd378c27 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 23 Apr 2017 23:05:42 +0200 Subject: 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 --- pkgs/lib/call-package-scope.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pkgs/lib/call-package-scope.nix (limited to 'pkgs/lib') 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 -- cgit 1.4.1