@@ -44,9 +44,23 @@ self: let
4444
4545 mkDerivation = makeOverridable mkDerivationImpl;
4646
47− callPackageWithScope = scope: drv: args: (stdenv.lib.callPackageWith scope drv args) // {
48− overrideScope = f: callPackageWithScope (mkScope (fix' (extends f scope.__unfix__))) drv args;
49− };
47+ callPackageWithScope = scope: fn: manualArgs:
48+ let
49+ # this code is copied from callPackage in lib/customisation.nix
50+ #
51+ # we cannot use `callPackage` here because we want to call `makeOverridable`
52+ # on `drvScope` (we cannot add `overrideScope` after calling `callPackage` because then it is
53+ # lost on `.override`) but determine the auto-args based on `drv` (the problem here
54+ # is that nix has no way to "passthrough" args while preserving the reflection
55+ # info that callPackage uses to determine the arguments).
56+ drv = if builtins.isFunction fn then fn else import fn;
57+ auto = builtins.intersectAttrs (builtins.functionArgs drv) scope;
58+ drvScope = allArgs: drv allArgs // {
59+ overrideScope = f:
60+ let newScope = mkScope (fix' (extends f scope.__unfix__));
61+ in callPackageWithScope newScope drv manualArgs;
62+ };
63+ in stdenv.lib.makeOverridable drvScope (auto // manualArgs);
5064
5165 mkScope = scope: pkgs // pkgs.xorg // pkgs.gnome2 // scope;
5266 defaultScope = mkScope self;