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
          ];
        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.

  • Shareni@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 day ago

    I just installed lazyvim and necessary packages through home-manager. I think I needed to install fonts through conf.nix, and that’s it.

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

      That is incredibly interesting. You didn’t have problems with treesitter failing to compile, or lsps and daps failing to run? What were the necessary packages that you installed? And how did you install lazyvim through home-manager, to begin with?

      • Shareni@programming.dev
        link
        fedilink
        English
        arrow-up
        4
        ·
        1 day ago

        Disregard everything. I just went to copy-paste what I installed and there’s no mention of lazyvim. There is a lazyvim package for nix, but I don’t seem to have used it.

        What were the necessary packages that you installed? And how did you install lazyvim through home-manager, to begin with?

        I just added these packages to home.nix, same should be for the package above. #neovim #git,make,npm,node,and ripgrep are already installed neovim python311 python311Packages.pip # python311Packages.pynvim luajitPackages.luarocks cargo git gh tree-sitter nerd-fonts.symbols-only emacsPackages.all-the-icons-nerd-fonts markdownlint-cli luajitPackages.jsregexp