pkgs/overlays/unstable-from-source: allow to provide callPackage
that means that you can build package from unstable, while using dependencies for a given unstable package from stable needs more testing with nested packages and package sets, but I don't see why it wouldn't work
This commit is contained in:
parent
a3735e02a9
commit
955083407e
1 changed files with 34 additions and 1 deletions
|
@ -1,10 +1,21 @@
|
|||
{
|
||||
unstableSource,
|
||||
attributeName ? "unstable",
|
||||
# callPackage :: function | boolean
|
||||
callPackage ? false,
|
||||
}:
|
||||
|
||||
self: super:
|
||||
|
||||
assert self.lib.assertMsg (
|
||||
self.lib.isFunction callPackage
|
||||
|| self.lib.isBool callPackage
|
||||
) ''
|
||||
callPackage argument should be a function or a boolean.
|
||||
If you want to use the callPackage from self, set it to true.
|
||||
If you want to use a custom callPackage, set it to a function (pkgs.callPackage).
|
||||
'';
|
||||
|
||||
let
|
||||
useUnstable = self.config.useUnstable or true;
|
||||
sanitizePlatform = platformConfig: self.lib.removeAttrs platformConfig [
|
||||
|
@ -34,7 +45,29 @@ let
|
|||
# when crossSystem is passed.
|
||||
crossSystem = sanitizePlatform self.stdenv.hostPlatform;
|
||||
};
|
||||
|
||||
callPackage' = if builtins.isFunction callPackage then callPackage
|
||||
else if builtins.isBool callPackage && callPackage then self.callPackage
|
||||
else if builtins.isBool callPackage && !callPackage then throw "this should never be evaluated"
|
||||
else throw "callPackage should be a function (callPackage) or a boolean";
|
||||
|
||||
callPackagesUnstablePkgs = self.lib.mapAttrsRecursiveCond (
|
||||
attrset: !(self.lib.hasAttr "override" attrset) && attrset.recurseForDerivations or false
|
||||
) (
|
||||
_: unstablePackage: callPackage' {
|
||||
# For some reason, override functor of the package has its argument set as required,
|
||||
# which is totally false! the override functor can take all of those arguemnts optionally.
|
||||
__functionArgs = self.lib.mapAttrs (_: _: true) (self.lib.functionArgs unstablePackage.override);
|
||||
__functor =
|
||||
if builtins.isFunction unstablePackage.override then unstablePackage.override
|
||||
else unstablePackage.override.__functor;
|
||||
} {}
|
||||
) unstablePkgs;
|
||||
|
||||
in
|
||||
{
|
||||
"${attributeName}" = if useUnstable then unstablePkgs else self;
|
||||
"${attributeName}" = if !useUnstable then self
|
||||
# if callPackage is not false
|
||||
else if builtins.isBool callPackage && !callPackage then callPackagesUnstablePkgs
|
||||
else unstablePkgs;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue