Merge pull request #151748 from hercules-ci/check-nixpkgs-overlays-type

Check nixpkgs overlays argument types

authored by Robert Hensing and committed by GitHub c253b04a be52ab78

+34 -2
+2 -1
lib/default.nix
··· 66 66 stringLength sub substring tail trace; 67 67 inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor 68 68 bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max 69 - importJSON importTOML warn warnIf info showWarnings nixpkgsVersion version 69 + importJSON importTOML warn warnIf throwIfNot 70 + info showWarnings nixpkgsVersion version 70 71 mod compare splitByAndCompare functionArgs setFunctionArgs isFunction 71 72 toHexString toBaseDigits; 72 73 inherit (self.fixedPoints) fix fix' converge extends composeExtensions
+22
lib/trivial.nix
··· 325 325 */ 326 326 warnIf = cond: msg: if cond then warn msg else id; 327 327 328 + /* 329 + Like the `assert b; e` expression, but with a custom error message and 330 + without the semicolon. 331 + 332 + If true, return the identity function, `r: r`. 333 + 334 + If false, throw the error message. 335 + 336 + Calls can be juxtaposed using function application, as `(r: r) a = a`, so 337 + `(r: r) (r: r) a = a`, and so forth. 338 + 339 + Type: bool -> string -> a -> a 340 + 341 + Example: 342 + 343 + throwIfNot (lib.isList overlays) "The overlays argument to nixpkgs must be a list." 344 + lib.foldr (x: throwIfNot (lib.isFunction x) "All overlays passed to nixpkgs must be functions.") (r: r) overlays 345 + pkgs 346 + 347 + */ 348 + throwIfNot = cond: msg: if cond then x: x else throw msg; 349 + 328 350 info = msg: builtins.trace "INFO: ${msg}"; 329 351 330 352 showWarnings = warnings: res: lib.foldr (w: x: warn w x) res warnings;
+10 -1
pkgs/top-level/default.nix
··· 49 49 in let 50 50 lib = import ../../lib; 51 51 52 + inherit (lib) throwIfNot; 53 + 54 + checked = 55 + throwIfNot (lib.isList overlays) "The overlays argument to nixpkgs must be a list." 56 + lib.foldr (x: throwIfNot (lib.isFunction x) "All overlays passed to nixpkgs must be functions.") (r: r) overlays 57 + throwIfNot (lib.isList crossOverlays) "The crossOverlays argument to nixpkgs must be a list." 58 + lib.foldr (x: throwIfNot (lib.isFunction x) "All crossOverlays passed to nixpkgs must be functions.") (r: r) crossOverlays 59 + ; 60 + 52 61 localSystem = lib.systems.elaborate args.localSystem; 53 62 54 63 # Condition preserves sharing which in turn affects equality. ··· 121 130 122 131 pkgs = boot stages; 123 132 124 - in pkgs 133 + in checked pkgs