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
      ·
      24 hours 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
        ·
        23 hours 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

  • lilbluntwrap@beehaw.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    1 day ago

    Here’s how I’ve got my nvim configured for nixos if you’re interested: https://codeberg.org/farrisswisher/nixos/src/branch/main/mod/user/nvim Mind you this is managed via homeManager but it should be mostly the same if you wanted to just use it in your regular nix rebuild rather than rely on homeManager

    Edit: to clarify, i’m posting this because the method of configuring nvim I’ve used here circumvents the need for lazyvim entirely, as you allow Nix to manage your plugins rather than lazyvim, packer, etc etc. You also can use it to manage all your various language LSPs so that eliminates the need for meson as well. All while still using lua for the actual configuration! Though one drawback I’ve had with this approach is that I did have some extra config files which I had to combine into the init.lua file, but other than that this has made the most sense to me, I hope it can prove helpful to you or anyone else who stops by here

    • beegnyoshi@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      24 hours ago

      Wow I skimmed through your config and it seemed really good! This is really simple and easy to understand. I made this post because I’d wanted to keep my lazyvim configuration, but if I were to want to completely rewrite it with nix from the ground up it’d likely either be with nixvim or something like yours!