Nix config with Home Manager and nixvim

Hello!

I’m struggling to understand the cause of an error while trying to add nixvim to my current Nix Flake/Home-Manager setup.

This is the error I’m currently getting:

Module `:anon-20:anon-1' has an unsupported attribute `defaultEditor'. 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: defaultEditor enable) into the explicit `config' attribute.

A similar error occurs if I remove the “defaultEditor” attribute, but instead it happens with “enable”. Indeed, removing both makes the error disappear, but I can’t see any of the nvim changes locally.

I did find a similar issue, but I have a mix of nixpkgs-25.05 and nixpkgs-unstable packages in use and (hopefully) only nixpkgs-unstable should be in use for home-manager and nixvim.

Here is a link to my full configuration.
Snippets of the most relevant files to the issue:

programs.nixvim doesn’t have a config option.

You need to remove that, and use the options you use in it one level upwards.

Whether nixvim actually understands those, no clue, but then the error will be one a bit better.

Thanks! That error really threw me down the wrong rabbit whole.
Once I removed the config block, everything started to fall into place (there were still some more minor issues, but those were clearly stated in the error messages now).