pkgs/overlays/unstable-from-source: fix infinite recursion in assert

also fix checking of callPackage argument, it was opposite
This commit is contained in:
Wroclaw 2025-06-01 19:45:20 +02:00
parent 955083407e
commit 2d88df163a

View file

@ -7,15 +7,6 @@
self: super: 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 let
useUnstable = self.config.useUnstable or true; useUnstable = self.config.useUnstable or true;
sanitizePlatform = platformConfig: self.lib.removeAttrs platformConfig [ sanitizePlatform = platformConfig: self.lib.removeAttrs platformConfig [
@ -49,7 +40,11 @@ let
callPackage' = if builtins.isFunction callPackage then callPackage callPackage' = if builtins.isFunction callPackage then callPackage
else if builtins.isBool callPackage && callPackage then self.callPackage else if builtins.isBool callPackage && callPackage then self.callPackage
else if builtins.isBool callPackage && !callPackage then throw "this should never be evaluated" else if builtins.isBool callPackage && !callPackage then throw "this should never be evaluated"
else throw "callPackage should be a function (callPackage) or a boolean"; else throw ''
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).
'';
callPackagesUnstablePkgs = self.lib.mapAttrsRecursiveCond ( callPackagesUnstablePkgs = self.lib.mapAttrsRecursiveCond (
attrset: !(self.lib.hasAttr "override" attrset) && attrset.recurseForDerivations or false attrset: !(self.lib.hasAttr "override" attrset) && attrset.recurseForDerivations or false
@ -68,6 +63,6 @@ in
{ {
"${attributeName}" = if !useUnstable then self "${attributeName}" = if !useUnstable then self
# if callPackage is not false # if callPackage is not false
else if builtins.isBool callPackage && !callPackage then callPackagesUnstablePkgs else if !(builtins.isBool callPackage && !callPackage) then callPackagesUnstablePkgs
else unstablePkgs; else unstablePkgs;
} }