appendOverlays: return spliced packages on empty overlay list

`appendOverlays []` returned `self` (the unspliced inner fixpoint)
while `import nixpkgs {}` returns `pkgs.__splicedPackages` (the
spliced version). This caused `pkgs.makeWrapper` and similar
spliced packages to lose their `__spliced` attribute after passing
through `appendOverlays`, breaking cross-compilation in NixOS
modules.

The NixOS `nixpkgs.nix` module calls `cfg.pkgs.appendOverlays
cfg.overlays`, and when no overlays are defined, the empty-list
short-circuit returned unspliced packages. This meant
`nativeBuildInputs = [ pkgs.makeWrapper ]` in NixOS modules would
evaluate the host-platform makeWrapper (which throws in cross
context) instead of being spliced to buildPackages.makeWrapper.

Fix by returning `self.__splicedPackages` instead of `self` for
the empty-list case.
This commit is contained in:
DavHau
2026-03-19 22:05:32 +08:00
parent c32aa27b81
commit 99ab2550e7
+4 -1
View File
@@ -264,7 +264,10 @@ let
# in one go when calling Nixpkgs, for performance and simplicity.
appendOverlays =
extraOverlays:
if extraOverlays == [ ] then self else nixpkgsFun { overlays = args.overlays ++ extraOverlays; };
if extraOverlays == [ ] then
self.__splicedPackages
else
nixpkgsFun { overlays = args.overlays ++ extraOverlays; };
# NOTE: each call to extend causes a full nixpkgs rebuild, adding ~130MB
# of allocations. DO NOT USE THIS IN NIXPKGS.