Setting up nixvim with home-manager

Hi, I am trying to set up nixvim with my home-manager configuration.

I added nixvim as an input to my flake like so:

nixvim = {
    url = "github:nix-community/nixvim";
    inputs.nixpkgs.follows = "nixpkgs";
};

and I added it to my outputs:

I then passed that module to home-manager:

homeConfigurations = {
  abrar = home-manager.lib.homeManagerConfiguration {
    inherit pkgs;
    modules = [ 
      ./home.nix
      nixvim.homeManagerModules.nixvim 
    ];
    extraSpecialArgs = { inherit pkgs-unstable; inherit spicetify-nix; };
  };
};

I set up some simple nixvim configuration (attached below), but when I try to switch to a new home-manager generation, I get this error:

error: Module `:anon-6:anon-1' has an unsupported attribute `colorschemes'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: colorschemes enable package plugins) into the explicit `config' attribute.

I have attached some pastebin’s so anyone looking can get the full picture:

flake.nix - Pastebin.com - flake.nix
home.nix - Pastebin.com - home.nix
nixvim.nix - Pastebin.com - nixvim.nix

Any help would be appreciated!

In nixvim.nix, you have nixvim as an input, but you haven’t passed it to extraSpecialArgs, so you’d either need to add it here:

# flake.nix
extraSpecialArgs = { inherit pkgs-unstable spicetify-nix nixvim; };

or remove it from the inputs:

# nixvim.nix
{ config, pkgs, lib, ... }:

Also, you probably shouldn’t set programs.nixvim.package = nixvim; as that option takes a Neovim package and not a flake input.

1 Like

Hi, thank you for the reply.

I added nixvim to the extraSpecialArgs for home-manager. I then tried to switch to a new home-manager generation but I still get the same error.

I tried doing the other method where I remove nixvim from the inputs of the nixvim.nix file, but I don’t add nixvim to the extraSpecialArgs in flake.nix but I still get this error.

I think I did like all possible combinations of adding to extraSpecialArgs and adding/removing nixvim from the inputs in nixvim.nix, but alas I still get these errors.

Maybe I’m just confusing your instructions here?

The issue could likely be that you’re trying to use an unstable nixvim with a stable nixpkgs. Try this, instead:

# flake.nix
inputs.nixvim = {
  url = "github:nix-community/nixvim/nixos-24.05";
  inputs.nixpkgs.follows = "nixpkgs";
};
1 Like

Yep, this seems to have been the issue! Everything seems to run properly now. Thanks for your help!

1 Like