summary refs log tree commit diff
path: root/pkgs/top-level/stage.nix
diff options
context:
space:
mode:
authordanbst <abcz2.uprola@gmail.com>2019-03-25 10:51:23 +0200
committerdanbst <abcz2.uprola@gmail.com>2019-03-25 10:58:46 +0200
commitf72903864d5e2be87bb532a516ee8d52c034a9fc (patch)
tree90d2cf6b090375e59c601b20ccd43eef6d02a0be /pkgs/top-level/stage.nix
parent5699e8edc7243fce3ed2332e76c04c7469f78d4b (diff)
downloadnixpkgs-f72903864d5e2be87bb532a516ee8d52c034a9fc.tar
nixpkgs-f72903864d5e2be87bb532a516ee8d52c034a9fc.tar.gz
nixpkgs-f72903864d5e2be87bb532a516ee8d52c034a9fc.tar.bz2
nixpkgs-f72903864d5e2be87bb532a516ee8d52c034a9fc.tar.lz
nixpkgs-f72903864d5e2be87bb532a516ee8d52c034a9fc.tar.xz
nixpkgs-f72903864d5e2be87bb532a516ee8d52c034a9fc.tar.zst
nixpkgs-f72903864d5e2be87bb532a516ee8d52c034a9fc.zip
pkgsMusl, pkgsi686Linux, pkgsStatic: fix infinite recursion with overlays
Consider example:

$ nix-instantiate ./nixos -A system --arg configuration '
    {
      boot.isContainer = true;
      nixpkgs.overlays = [ (self: super: {
        nix = self.pkgsStatic.nix;
      }) ];
    }'

When resolving package through overlays, we figure out that

  nix == self.pkgsStatic.nix
  =>
  nix == (import <nixpkgs> { inherit overlays; }).nix
  =>
  nix == (import <nixpkgs> { overlays = [(self: super: { nix = self.pkgsStatic.nix; })];}).nix

and we enter infinite recursion of nixpkgs evaluations.

The proper fix should terminate recursion by assigning self fixpoint
to inner custom package set. But I get infinite recursion somehow, so
I use `super`. It is less correct modulo deep custom overrides, but behaves
correctly for simple cases and doesn't OOM evaluator.

Fixes https://github.com/NixOS/nixpkgs/issues/57984
Diffstat (limited to 'pkgs/top-level/stage.nix')
-rw-r--r--pkgs/top-level/stage.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix
index 0ee5c25b010..357ca5246c9 100644
--- a/pkgs/top-level/stage.nix
+++ b/pkgs/top-level/stage.nix
@@ -135,6 +135,9 @@ let
     # default GNU libc on Linux systems. Non-Linux systems are not
     # supported.
     pkgsMusl = if stdenv.hostPlatform.isLinux then nixpkgsFun {
+      overlays = [ (self': super': {
+        pkgsMusl = super';
+      })] ++ overlays;
       ${if stdenv.hostPlatform == stdenv.buildPlatform
         then "localSystem" else "crossSystem"} = {
         parsed = stdenv.hostPlatform.parsed // {
@@ -151,6 +154,9 @@ let
     # All packages built for i686 Linux.
     # Used by wine, firefox with debugging version of Flash, ...
     pkgsi686Linux = if stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86 then nixpkgsFun {
+      overlays = [ (self': super': {
+        pkgsi686Linux = super';
+      })] ++ overlays;
       ${if stdenv.hostPlatform == stdenv.buildPlatform
         then "localSystem" else "crossSystem"} = {
         parsed = stdenv.hostPlatform.parsed // {
@@ -176,6 +182,9 @@ let
     # Fully static packages.
     # Currently uses Musl on Linux (couldn’t get static glibc to work).
     pkgsStatic = nixpkgsFun ({
+      overlays = [ (self': super': {
+        pkgsStatic = super';
+      })] ++ overlays;
       crossOverlays = [ (import ./static.nix) ];
     } // lib.optionalAttrs stdenv.hostPlatform.isLinux {
       crossSystem = {