Hey all. Last time I searched about how to make LazyVim “just work” in nixos (which it didn’t mostly because of mason and treesitter) was a few years ago, so maybe if I were to try to do it again nowadays I would find a better solution but anyway.

When I first switched to nixos, I already had my neovim config, and I wanted it to just work in my new system. I didn’t want to rewrite it in nix or manually install treesitter grammar packages or lsps. Alas, due to nixos not following FHS, it didn’t work.

So, a few days ago, here’s what I seem to have found as a solution: Adding this:

      (pkgs.buildFHSEnv {
        name = "nvim";
        multiPkgs = pkgs:
          with pkgs; [
            libz # For codelldb to work
            icu # For marksman to work
          ];
        targetPkgs = pkgs:
          with pkgs; [
            neovim
            # Whatever other things you need inside neovim
            gnumake # for compiling some plugins
          ];
        runScript = "nvim";
      })

To my environment.systemPackages.

Note that I wasn’t using steam-run because I remember I got a ton of errors when I tried it a few years ago, though it seemed to work normally when I tried it just now. I still think that this is a better way to go about it than to use steam-run nvim every time, though. I also haven’t tested this all that much, so it might have some sort of caveat I have yet to discover.

Hopefully this post helps someone.

Edit: Added icu for marksman

  • beegnyoshi@lemmy.zipOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 month ago

    Yep! What I wanted was for a “just works” experience as much as possible. Having to manually install lsps and treesitter parsers manually with nix felt like a bummer, honestly. It does work though

    • axEl7fB5@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      1 month ago

      you can also use:

      require("nvim-treesitter.configs").setup({
        ensure_installed = {
          "foo",
          "bar
        },
      })
      

      in your neovim config if :TSInstall isn’t good enough