the-argus / spicetify-nix

A nix flake for configuring spicetify. Includes packaging for many popular themes and extensions.
GNU General Public License v3.0
135 stars 22 forks source link

NixOS: Cannot install - infinite recursion #30

Open hermann-p opened 12 months ago

hermann-p commented 12 months ago

In my home-manager on NixOS, I added the flake input and activated the program just as the readme suggested. When building the new home-manager generation, it will fail with

error: infinite recursion encountered

       at /nix/store/j3cnzmjq5b3naz1nckh6p39fnkaabv5d-source/lib/modules.nix:506:28:

          505|         builtins.addErrorContext (context name)
          506|           (args.${name} or config._module.args.${name})
             |                            ^
          507|       ) (lib.functionArgs f);

I disabled all optional extensions, so it must be something within the core module.

Home manager `flake.nix`

```nix { description = "Home Manager configuration"; inputs = { spicetify-nix.url = "github:the-argus/spicetify-nix"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; inputs.nixos.follows = "nixos"; }; }; outputs = { nixpkgs, emacs-overlay, home-manager, ... }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; in { homeConfigurations."hermann" = home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ ./home.nix ]; }; }; } ```

My home.nix imports spicetify.nix

spicetify.nix

```nix { spicetify-nix, config, lib, pkgs, ... }: let spicePkgs = spicetify-nix.packages.${pkgs.system}.default; in { # allow spotify to be installed if you don't have unfree enabled already nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "spotify" ]; # import the flake's module for your system imports = [ spicetify-nix.homeManagerModule ]; # configure spicetify :) programs.spicetify = { enable = true; theme = spicePkgs.themes.catppuccin-mocha; colorScheme = "flamingo"; enabledExtensions = with spicePkgs.extensions; [ ... ]; }; } ```

the-argus commented 11 months ago

@hermann-p None of this looks immediately wrong to me. However there are some small things:

You are using legacyPackages.${system} as your package set. Try doing pkgs = import nixpkgs { localSystem = {inherit system;}}; instead, might be a simple fix. If it works, let me know and I'll update the readme to say that legacyPackages isn't supported.

You could also try changing outputs = { nixpkgs, emacs-overlay, home-manager, ... }: to outputs = { nixpkgs, emacs-overlay, home-manager, ... } @ inputs:. This gives you inputs as a reference to all of your flake inputs. Then you can add extraSpecialArgs to your home configuration like so:

      homeConfigurations."hermann" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        modules = [ ./home.nix ];
        extraSpecialArgs = inputs;
      };

This assures that you're telling home-manager's homeManagerConfiguration function to pass the spicetify-nix flake input to all of your modules (home.nix in this case).

If neither of these fix the problem, please upload your config (or a stripped-down version of it with the issue) to a repository so I can look at it further.

aliyss commented 11 months ago

outputs = { nixpkgs, emacs-overlay, home-manager, ... } @ inputs: extraSpecialArgs = inputs;

This did it for me.

hermann-p commented 11 months ago

@the-argus Oops, bad comment, I had spicetify commented out. I needed to add the extra special args, too.

the-argus commented 11 months ago

Glad it solved it. Leaving this open for now, until I find a good explanation and add some context about the issue to the readme.

hermann-p commented 11 months ago

Thanks for your time and the help :)

eclairevoyant commented 8 months ago

This is offtopic for the issue, but for anyone new who lands here:

You are using legacyPackages.${system} as your package set. Try doing pkgs = import nixpkgs { localSystem = {inherit system;}}; instead

This is completely backwards. nixpkgs.legacyPackages.${system} is preferred when possible.

I'll update the readme to say that legacyPackages isn't supported.

There's no difference, other than with the import you are unnecessarily instantiating nixpkgs and slowing down evaluation.

Leaving this open for now, until I find a good explanation

The error message indicates this already, this is infrec due to a missing module arg.

ilovethensa commented 6 months ago

any updates on this? cant get it to work

eclairevoyant commented 6 months ago

any updates on this? cant get it to work

Read the comment above yours