Recently I've been learning about Nix. At first my impression was not good: what it would provide that Docker can't? Then I went the other extreme: now I'm seeing its utility everywhere.

I have a dotfiles repository that I use to set up my environment. One part of it is my neovim config. Over the years I've been adding various stuff to it: plugins, keymaps, language servers, some custom configuration.

Even though the dotfiles should install everything, neovim is always broken at first and I need to fix it. This is because it uses a lot of different things:

  • Vim plug installs the current version of plugins
  • Mason installs the language servers
  • Plugins need tools, such as Telescope needs ripgrep, gitsigns needs git

Nix's promise here is that I can have a binary that reliably contains everything that nvim needs. It manages plugins, language servers, compilers, and all the other tools plugins need.

I was a bit afraid to start working on it, as there are horror stories where people more familiar with Nix failed. But I had some free time in the past weeks and made the jump.

The result: I have a working nvim config and I'm already using it for my daily driver. Surprisingly, it turned out to be way easier than expected: all the plugins I use are available in the Nixpkgs.

With this, I can do a nix-build and then start with result/bin/nvim. I have it aliased in my shell so nvim will also work.

As an added benefit I could configure Landlock with it. By default it can only access the current directory, a few extra files, and no internet. That should limit the damage any of the various plugins and tools can do.

So far, I'm happy with this.

Originally published at advancedweb.hu

Advanced Web MachinerySource