nixos/nixpkgs: Make default Nixpkgs lazy when overridden

+9 -1
+9 -1
nixos/modules/misc/nixpkgs.nix
··· 337 337 338 338 config = { 339 339 _module.args = { 340 - pkgs = finalPkgs.__splicedPackages; 340 + pkgs = 341 + # We explicitly set the default override priority, so that we do not need 342 + # to evaluate finalPkgs in case an override is placed on `_module.args.pkgs`. 343 + # After all, to determine a definition priority, we need to evaluate `._type`, 344 + # which is somewhat costly for Nixpkgs. With an explicit priority, we only 345 + # evaluate the wrapper to find out that the priority is lower, and then we 346 + # don't need to evaluate `finalPkgs`. 347 + lib.mkOverride lib.modules.defaultOverridePriority 348 + finalPkgs.__splicedPackages; 341 349 }; 342 350 343 351 assertions = [