KFearsoff / NixOS-config

MIT License
20 stars 0 forks source link

packpathDirs #56

Closed shot-codes closed 4 months ago

shot-codes commented 5 months ago

Heya, I've been struggling trying to get lazyvim lsps working in nixos at all and came across your own config. I've made a minimal setup emulating yours following your guide but something is going wrong when trying to inform lazy of the package directory. Any tips to help me figure out why I don't have home-manager in config would be much appreciated :)

dev = {
  path = "${pkgs.vimUtils.packDir config.home-manager.users.shot.programs.neovim.finalPackage.passthru.packpathDirs}/pack/myNeovimPackages/start",
  patterns = {"folke"},
},
       error: attribute 'home-manager' missing

       at /nix/store/10d4j8a6sa4j93sy1hqakp3wgi71s1mj-source/home/neovim/default.nix:36:43:

           35|         dev = {
           36|           path = "${pkgs.vimUtils.packDir config.home-manager.users.shot.programs.neovim.finalPackage.passthru.packpathDirs}/pack/myNeovimPackages/start",
             |                                           ^
           37|   patterns = {"folke"},
KFearsoff commented 5 months ago

Nice catch!

You are importing Neovim Nix file as a Home Manager module, not as a NixOS module. I'm doing NixOS-level imports for... perhaps not great reasons, but yeah. This is where you import the HM module:

https://github.com/shot-codes/nix/blob/c1777ea48f9b76844fe2f2862041704ad95beb8b/flake.nix#L51

HM modules get config argument scoped to the HM modules, and NixOS modules get, uhh, global (?) scope. The config argument you have in HM modules can only access the HM modules, and can't access NixOS modules. home-manager.users.shot is a NixOS module path; HM module path would be programs.neovim.finalPackage.passthru.packpathDirs, which can also be accessed by home-manager.users.shot.programs.neovim.finalPackage.passthru.packpathDirs as a NixOS module.

So long story short, you need to use the correct scope here, which you can do in either of those two ways:

  1. Change config to osConfig; osConfig is an argument for HM modules that contains the config for NixOS modules
  2. Change the reference from config.home-manager.users.shot.programs.neovim.finalPackage.passthru.packpathDirs to config.programs.neovim.finalPackage.passthru.packpathDirs; you are already scoped into home-manager.users.shot, so there's no actual need to reference it again
evanaze commented 4 months ago

This helped me a lot too. Thank you for asking the question shot-codes and thanks for the thorough solution KFearsoff!

shot-codes commented 4 months ago

Haha glad I could help. I ended up switching to nixvim and have been too busy to stay on top of my created github issues. I'll go ahead and close the issue since I am no longer in a position to try the fix and I'm confident from your response KFearsoff that this will work if I try again in the future, it seems to have worked for evanaze :) <3