Commit 99ab2550 authored by DavHau's avatar DavHau
Browse files

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.
parent c32aa27b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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.