From a742767bafecf0644585309b744e24f90cdff207 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 16 Jun 2023 21:28:06 +0200 Subject: [PATCH] nixos/nixpkgs: Make default Nixpkgs lazy when overridden --- nixos/modules/misc/nixpkgs.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index 55ec08acf445..8a20e31d5137 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -337,7 +337,15 @@ in config = { _module.args = { - pkgs = finalPkgs.__splicedPackages; + pkgs = + # We explicitly set the default override priority, so that we do not need + # to evaluate finalPkgs in case an override is placed on `_module.args.pkgs`. + # After all, to determine a definition priority, we need to evaluate `._type`, + # which is somewhat costly for Nixpkgs. With an explicit priority, we only + # evaluate the wrapper to find out that the priority is lower, and then we + # don't need to evaluate `finalPkgs`. + lib.mkOverride lib.modules.defaultOverridePriority + finalPkgs.__splicedPackages; }; assertions = [