EdenEast / nyx

⚙️Nix[OS] Configuration
The Unlicense
148 stars 10 forks source link

What's your workflow for changing neovim config? #72

Closed WilliamHsieh closed 1 year ago

WilliamHsieh commented 1 year ago

Hi, I just came across your nyx setup, and I am super interested in your workflow of nix. Currently, I'm using stow to manage my dotfiles, so modifying my neovim config is as easy as saving quit and reopening. But from my understanding of home manager, isn't home-manager switch required after each config modification? It seems like extra overhead for me. Is it how you do it, or is there another way to do it? Just curious about the whole nix idea. I would like to switch to nix, but I'm not sure what problem it solves for me besides the declarative package manager provided by home-manger. It would be great if you are willing to share some of your experiments in nix. Not sure where to contact you though, feel free to delete the issue if it bothers you :) Thank's for the inspiration BTW.

EdenEast commented 1 year ago

Glad that you can get some inspiration from my config. To provide a wider context for my config in general, I use many machines / systems that span across windows, mac, and linux. My previous config was an overly complicated ansible setup and then migrated to salt for better windows support. Now I use nix to handle mostly my mac, nixos, and wsl setup. Nix is great for handling your system configuration but one issue is that it is an all or nothing kind of approach. So my config mainly uses nix but not all of it.

Because I use systems that nix does not support (*cough* windows) and some configuration like my neovim constantly change I keep some of my configurations in my config folder at the root of my configuration. You can think of that folder as the root of my $HOME folder on a system.

So with that out of the way, to your actual question about neovim. I use nix to install neovim and the tools that I use with it (like lsp, linters, etc). My neovim config lives at config/.config/nvim. I use nix to link ~/.config/nvim to config/.config/nvim.

The relevant section would be: https://github.com/EdenEast/nyx/blob/dc87aef1ab52d041dc407bc337d06eb85ae1e4c6/home/modules/shell/neovim.nix#L65

Note that this does not create a link to where ever I have my config checkout locally. It still links to a section in the /nix/store.

When I want to make changes to my neovim configuration I use a shell script also called nyx to create a symlink from ~/.config/nvim to where ever I have nyx cloned locally. I just call nyx link nvim. You can see the link command here: https://github.com/EdenEast/nyx/blob/dc87aef1ab52d041dc407bc337d06eb85ae1e4c6/bin/nyx#L294-L416

Now you dont have to over engineer something like this but hope this has helped explain some of my current setup. Please let me know if you have any follow up questions. Happy to help, nix is something that is not easy to learn (it is getting better) so it helps if you are able to ask someone.

WilliamHsieh commented 1 year ago

After doing some research, the solution from this issue https://github.com/nix-community/home-manager/issues/2085 seems to solve my problem. Thanks for your sharing, I'll definitely try to migrate my dotfiles to a flake in the future!

EdenEast commented 1 year ago

Thanks @WilliamHsieh for letting me know that mkOutOfStorageSymlink exists will look into that as well.