From 8fafec586ef681d4b4196a6554f55d8e27fe7477 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 23 Apr 2017 22:30:17 +0200 Subject: pkgs: Improve callPackageScope customisation By default callPackageWith adds an overrideDerivation attribute, but that won't work with our new package scopes, so we add an override attribute by ourselves without the overrideDerivation attribute. That aside, we now use functionArgs on not only the superset of packages but also for the scope utility functions (callPackage/callPackage_i686) that we pass down to our new package scope. If we didn't do that, the Nix expression of the subscope would always need to define callPackage and callPackage_i686 in their function arguments, regardless of whether it's needed or not. Signed-off-by: aszlig --- pkgs/default.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'pkgs/default.nix') diff --git a/pkgs/default.nix b/pkgs/default.nix index 5bb1316d..8b6050c7 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,17 +1,33 @@ { pkgs ? import (import ../nixpkgs-path.nix) {} }: let - inherit (pkgs.lib) callPackageWith; + inherit (pkgs.lib) callPackageWith isFunction; callPackage = callPackageWith (pkgs // self.vuizvui); callPackage_i686 = callPackageWith (pkgs.pkgsi686Linux // self.vuizvui); callPackageScope = fn: let + f = if isFunction fn then fn else import fn; + toplevel = pkgs // self.vuizvui; toplevel_i686 = pkgs.pkgsi686Linux // self.vuizvui; - super = callPackageWith toplevel fn { + + autoArgs = toplevel // { callPackage = callPackageWith (toplevel // super); callPackage_i686 = callPackageWith (toplevel_i686 // super); }; + args = builtins.intersectAttrs (builtins.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; self.vuizvui = pkgs.recurseIntoAttrs { -- cgit 1.4.1