Flake example on website leads to infinite recursion #63

Open
opened 2025-11-10 19:59:35 +00:00 by sliedes · 1 comment

https://lix.systems/add-to-config/ gives this snippet as a "fancier alternative" to switch to Lix on NixOS:

{ pkgs, ... }:
{
  nixpkgs.overlays = [ (final: prev: {
    inherit (prev.lixPackageSets.stable)
      nixpkgs-review
      nix-eval-jobs
      nix-fast-build
      colmena;
  }) ];

  nix.package = pkgs.lixPackageSets.stable.lix;
}

I tried it; the result is an infinite recursion:

┏━ 1 Errors:                                                                                                                            
┃ error:                                                                                                                                
┃        … while calling the 'head' builtin                                                                                             
┃          at /nix/store/z9bsnmxm84byj7yjxl19d9qgxvm5jcqf-source/lib/attrsets.nix:1696:13:                                              
┃          1695|           if length values == 1 || pred here (elemAt values 1) (head values) then                                      
┃          1696|             head values                                                                                                
┃              |             ^                                                                                                          
┃          1697|           else                                                                                                         
┃                                                                                                                                       
┃        … while evaluating the attribute 'value'                                                                                       
┃          at /nix/store/z9bsnmxm84byj7yjxl19d9qgxvm5jcqf-source/lib/modules.nix:1118:7:                                                
┃          1117|     // {                                                                                                               
┃          1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;                                
┃              |       ^                                                                                                                
┃          1119|       inherit (res.defsFinal') highestPrio;                                                                            
┃                                                                                                                                       
┃        (stack trace truncated; use '--show-trace' to show the full trace)                                                             
┃                                                                                                                                       
┃        error: infinite recursion encountered                                                                                          
┃        at /nix/store/z9bsnmxm84byj7yjxl19d9qgxvm5jcqf-source/pkgs/tools/package-management/lix/default.nix:105:28:                    
┃           104|                                                                                                                        
┃           105|           nixpkgs-review = nixpkgs-review.override {                                                                   
┃              |                            ^                                                                                           
┃           106|             nix = self.lix;                                                                                            
┣━━━                                                                                                                                    
┗━ ∑ ⚠ Exited with 1 errors reported by nix at 20:47:58 after 10s                                                                       
https://lix.systems/add-to-config/ gives this snippet as a "fancier alternative" to switch to Lix on NixOS: ```nix { pkgs, ... }: { nixpkgs.overlays = [ (final: prev: { inherit (prev.lixPackageSets.stable) nixpkgs-review nix-eval-jobs nix-fast-build colmena; }) ]; nix.package = pkgs.lixPackageSets.stable.lix; } ``` I tried it; the result is an infinite recursion: ``` ┏━ 1 Errors: ┃ error: ┃ … while calling the 'head' builtin ┃ at /nix/store/z9bsnmxm84byj7yjxl19d9qgxvm5jcqf-source/lib/attrsets.nix:1696:13: ┃ 1695| if length values == 1 || pred here (elemAt values 1) (head values) then ┃ 1696| head values ┃ | ^ ┃ 1697| else ┃ ┃ … while evaluating the attribute 'value' ┃ at /nix/store/z9bsnmxm84byj7yjxl19d9qgxvm5jcqf-source/lib/modules.nix:1118:7: ┃ 1117| // { ┃ 1118| value = addErrorContext "while evaluating the option `${showOption loc}':" value; ┃ | ^ ┃ 1119| inherit (res.defsFinal') highestPrio; ┃ ┃ (stack trace truncated; use '--show-trace' to show the full trace) ┃ ┃ error: infinite recursion encountered ┃ at /nix/store/z9bsnmxm84byj7yjxl19d9qgxvm5jcqf-source/pkgs/tools/package-management/lix/default.nix:105:28: ┃ 104| ┃ 105| nixpkgs-review = nixpkgs-review.override { ┃ | ^ ┃ 106| nix = self.lix; ┣━━━ ┗━ ∑ ⚠ Exited with 1 errors reported by nix at 20:47:58 after 10s ```

I have hit this issue as well, the problem is that pkgs.lixPackageSets is a scope created with pkgs.callPackage. It tries to set, for example, stable.nixpkgs-review = pkgs.nixpkgs-review.override { nix = stable.lix; };. With the suggested overlay, pkgs.nixpkgs-review is pkgs.lixPackageSets.stable.nixpkgs-review, so it tries to override its own output rather than nixpkgs' default.

I found an ugly workaround by adding an extra level of override: overriding arguments of pkgs.lixPackageSets to those of overlay's prev, forcing lixPackageSets to override original packages:

_final: prev: let
  lixPackageSets = prev.lixPackageSets.override {inherit (prev) colmena nix-direnv nix-fast-build nix-update nixpkgs-review;};
in {
  inherit lixPackageSets;
  inherit
    (lixPackageSets.stable)
    colmena
    lix
    nix-direnv
    nix-eval-jobs
    nix-fast-build
    nix-update
    nixpkgs-review
    ;
}
I have hit this issue as well, the problem is that `pkgs.lixPackageSets` is a scope created with `pkgs.callPackage`. It tries to set, for example, `stable.nixpkgs-review = pkgs.nixpkgs-review.override { nix = stable.lix; };`. With the suggested overlay, `pkgs.nixpkgs-review` is `pkgs.lixPackageSets.stable.nixpkgs-review`, so it tries to override its own output rather than nixpkgs' default. I found an ugly workaround by adding an extra level of override: overriding arguments of `pkgs.lixPackageSets` to those of overlay's `prev`, forcing `lixPackageSets` to override original packages: ```nix _final: prev: let lixPackageSets = prev.lixPackageSets.override {inherit (prev) colmena nix-direnv nix-fast-build nix-update nixpkgs-review;}; in { inherit lixPackageSets; inherit (lixPackageSets.stable) colmena lix nix-direnv nix-eval-jobs nix-fast-build nix-update nixpkgs-review ; } ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix-website#63
No description provided.