BirdeeHub/nixCats-nvim: A Lua-natic nix user's Neovim Flake

This is a flake for beginner and advanced nix users alike. Configure neovim like normal, give up on 0 nix integration options, only ever need one directory. Importable as flake or home/system module.

has a wrapper for lazy.nvim and pckr in case you want your config to work without nix, convenient system for passing info from nix into lua, extensive in editor documentation on usage, many templates.



Hi! Iā€™m the person (one of?) who discussed this quite a bit with you on Reddit. Glad to see the project is alive and well!

1 Like

Its pretty nice :slight_smile: Im probably never even going to use the lazy wrapper but it works great XD

The project is going to stay around lol my main config for nvim for my system literally imports the builder from github like one of the templates. Ill keep it up to date and stuff because it IS the builder for my main neovim config. Help from anyone with readme and help though is greatly appreciated lol

glad to see youre around as well :slight_smile:

very impressive and my current solution to this is super hacky, so i will have to check this out!

1 Like

I mean, nixCats isnt like, not hacky, but its not that complex when you get into it and it ends up being fairly elegant to use at the end and Ive been using it for months at this point and not had any issues.

How it works in a nutshell is this:

I sort some categories based on a nix table. Then I write a function to turn nix set to lua table and print the mentioned set to a file and add it as a lua plugin. I write a convenience lua function to make checking which things you have in that lua table not painful.

Then I basically just add the entire luaPath, (by default ./.) to the runtime path.

Then I use the pkgs.wrapNeovim function on the sorted categories with the extra nixCats plugin and the config file added

Then I make it export a home manager and nixos module with the same options as the flake.

Then I realized I needed more info to solve some issues with treesitter+lazy so I turned the nixCats plugin with all the lua tables into a function and passed it way down into the wrapper function so that I could also pass out that info.

Then I made it make the original wrapper script name the same as the name in packageDefinitions instead of nvim, allowing multiple neovims to be installed without causing collision errors, at the cost of being able to launch it via the nvim command (but I remembered to change the .desktop file and I also made it so you can name it whatever else you want at the same time, and the nvim in the store is still named nvim so it doesnt cause bugs).

Then i wrote some utilities for setting up neovim package managers with the correct options for good cooperation, such as lazy.nvim

And thats kinda it really.

Oh and I wrote a lot of in-editor help for it and made the builder add that to the nixCats plugin so it is properly integrated

How the flake exports that stuff:

All of that is done within the nix folder, and what the user is presented with is the utils set in flake.nix which is effectively the api. usage is covered in the templates and help. The utils set is a subset of the ./nix/utils/default.nix file, named utils and defined at the top of that file. So in the original it is imported with (import ./nix/utils).utils and then when you use it, you will use inputs.nixCats.utils
Usage of this set is covered in the help, but reading the source is never a bad idea. Plus, right below it you can see how to print a nix set to a lua table and isnt that cool XD

The system independent utils set in flake.nix and exported from nixCats flake contains the builder, and all utils and templates and help you will need to use the format. All that is needed to use any feature of nixCats in your own flake is the utils set exported by the nixCats flake (and also as passthrough by any nixCats based package), the rest is convenience, documentation and example.

The only actually original stuff is the format of the flake (the module options follow an adaptation of the same format), and then in nix/utils directory and nix/builder/{default.nix, nixCats.lua}

The rest of the nix directory is either help, templates, or moderately modified nixpkgs source to pass out some extra functionality and/or info. Tthe lua in the original flake is just an example, as is the flake.nix in the original. If you have a question, see how I did it there, or read the help.

Because all of the workings of the project are exported via the utils set, your configuration will not have the nix directory the original does, all the features of that directory will instead be imported via the utils set from the nixCats flake input.

Check out the templates for how to begin, they can be initialized into an empty directory, and some are also suitable for initializing directly into your existing neovim config directory. Refer to the help which will always be accessible, the original nixCats flake or the templates if you ever are confused about something related to nixCats for an example