Misterio77 / nix-colors

Modules and schemes to make theming with Nix awesome.
GNU General Public License v3.0
465 stars 38 forks source link

Infinite Recursion Error on Standalone Legacy Setup #23

Closed jhilker98 closed 1 year ago

jhilker98 commented 2 years ago

Hi there,

I'm currently trying out nix and home-manager in a virtual machine, and I'd like to be able to use this module for creating a colorscheme setup. Here is my current HM config (standalone in EndeavourOS), though any time I run `home-manager switch, I get an infinite-recursion error whenever I try to import the module:

{ config, pkgs, nix-colors ? import <nix-colors> { },... }:  {
 ...
  targets.genericLinux.enable = true;
  fonts.fontconfig.enable = true;

  imports = [ nix-colors.homeManagerModule ];
  extraSpecialArgs = { inherit nix-colors; };
  colorScheme = nix-colors.colorSchemes.dracula;
}
...

I'm still fairly new to nix, so if I had done something wrong please let me know. If you need the entire config, here is the link to it.

MLarsenPR commented 2 years ago

Having the same issue, I have the channel added but don't understand the step spelled out here:

Then, at the top of your config file(s) add nix-colors ? import { } as an argument (instead of just nix-colors).

Believe this is to be done to the configuration.nix but it's not clear to me how this needs to be formatted.

Misterio77 commented 2 years ago

Hey!

I think the issue is that you're getting nix-colors from the module argument and passing it to extraSpecialArgs, thus creating an infinite recursion.

Try this (don't pass extraSpecialArgs, but you'll have to nix-colors ? <nix-colors> on every module file):

{ config, pkgs, nix-colors ? import <nix-colors> { },... }:  {
 ...
  targets.genericLinux.enable = true;
  fonts.fontconfig.enable = true;

  imports = [ nix-colors.homeManagerModule ];
  colorScheme = nix-colors.colorSchemes.dracula;
}
...

Or this:

{ config, pkgs, ... }:  {
 ...
  targets.genericLinux.enable = true;
  fonts.fontconfig.enable = true;

  imports = [ nix-colors.homeManagerModule ];
  extraSpecialArgs = { nix-colors = import <nix-colors> { }; };
  colorScheme = nix-colors.colorSchemes.dracula;
}
...
Misterio77 commented 2 years ago

Believe this is to be done to the configuration.nix but it's not clear to me how this needs to be formatted.

Sorry if the README doesn't make it very clear, but the general idea is:

flakes + home-manager standalone

flake.nix:

{
  inputs = {
    # ...
    nix-colors.url = "github:NixOS/nix-colors";
  };
  outputs = { nixpkgs, home-manager, ... }: {
    homeConfigurations = {
      "you@computer" = home-manager.lib.homeManagerConfiguration {
          # ...
          modules = [ ./home.nix ];
          extraSpecialArgs = { inherit nix-colors; };
      };
    };
  };
}

home.nix:

{ nix-colors, ... }: {
  imports = [ nix-colors.homeManagerModules.colorschemes ];
  colorScheme = nix-colors.colorSchemes.dracula;
}

flakes + home-manager as nixos module

flake.nix:

{
  inputs = {
    # ...
    nix-colors.url = "github:NixOS/nix-colors";
  };
  outputs = { nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      computer = nixpkgs.lib.nixosSystem {
          # ...
          modules = [ ./configuration.nix ];
          specialArgs = { inherit nix-colors home-manager; };
      };
    };
  };
}

configuration.nix:

{ nix-colors, home-manager, ... }:
{
  imports = [ home-manager.nixosModules.home-manager ];

  home-manager = {
    # ...
    users.you = import ./home.nix;
    extraSpecialArgs = { inherit nix-colors; };
  };
}

home.nix:

{ nix-colors, ... }: {
  imports = [ nix-colors.homeManagerModules.colorschemes ];
  colorScheme = nix-colors.colorSchemes.dracula;
}

legacy + home-manager standalone

home.nix:

{ nix-colors ? import <nix-colors> { }, ... }: {
  imports = [ nix-colors.homeManagerModules.colorschemes ];
  colorScheme = nix-colors.colorSchemes.dracula;
}

legacy + home-manager as nixos module

configuration.nix:

{ nix-colors ? import <nix-colors> { }, home-manager ? import <home-manager> { }, ... }:
{
  imports = [ home-manager.nixosModules.home-manager ];

  home-manager = {
    # ...
    users.you = import ./home.nix;
    extraSpecialArgs = { inherit nix-colors; };
  };
}

home.nix:

{ nix-colors, ... }: {
  imports = [ nix-colors.homeManagerModules.colorschemes ];
  colorScheme = nix-colors.colorSchemes.dracula;
}

legacy + home-manager as nixos module (alternative)

configuration.nix:

{ home-manager ? import <home-manager> { }, ... }:
{
  imports = [ home-manager.nixosModules.home-manager ];

  home-manager = {
    # ...
    users.you = import ./home.nix;
  };
}

home.nix:

{ nix-colors ? import <nix-colors> { }, ... }: {
  imports = [ nix-colors.homeManagerModules.colorschemes ];
  colorScheme = nix-colors.colorSchemes.dracula;
}
jhilker98 commented 2 years ago

Alright, I'll try that. Thanks for the suggestion, and I'll keep you updated.No worries about it not being clear, I'm still brand new to nix.

MLarsenPR commented 2 years ago

2022-07-08_17-15 home.nix.tar.gz

Having so many installation methods with their own ways of doing things has certainly been a pain point of learning this. I'm in the legacy + stand alone home manager camp. I've attached a screenshot of the error and a copy of my current home.nix. I've still got the same issue with those changes.

Is there anything that needs to be done in the configuration.nix? Not sure what I'm missing here.

Thanks,

Misterio77 commented 1 year ago

Hey @MLarsenPR. I totally missed your comment, sorry :(

If you're still facing trouble, try this

let
  nix-colors = import <nix-colors> { };
in {
  imports = [ nix-colors.homeManagerModules.colorschemes ];
  colorScheme = nix-colors.colorSchemes.dracula;
}

I reproduced your error, and am really confused why putting it in the module header has stopped working (perhaps it never worked?)... But well, this should get you going.

I'll update the readme to reflect this

jhilker98 commented 1 year ago

I got it working with Nix Flakes. Thanks though!

On Sun, Aug 21, 2022, 10:21 PM Gabriel Fontes @.***> wrote:

Hey @MLarsenPR https://github.com/MLarsenPR. I totally missed your comment, sorry :(

If you're still facing trouble, try this

let nix-colors = import { };in { imports = [ nix-colors.homeManagerModules.colorschemes ]; colorScheme = nix-colors.colorSchemes.dracula; }

I reproduced your error, and am really confused why putting it in the module header has stopped working... But well, this should get you going.

I'll update the readme to reflect this

— Reply to this email directly, view it on GitHub https://github.com/Misterio77/nix-colors/issues/23#issuecomment-1221714840, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACY54OBRWZBS5YKG7NP5P33V2LPZPANCNFSM5226JSQQ . You are receiving this because you authored the thread.Message ID: @.***>