MatthiasBenaets/nix-config

How are you generating tree heirarchy at the top of each .nix file?

Closed this issue · 4 comments

Hello,

I am liking your config structure quite a bit so far, and have adapted it to my needs. I would like to know how the file tree representations at the top of each nix file are being generated and applied relative to flake.nix. Does this happen automatically? I am already using nixpkgs-fmt to auto format all of my configs, so auto generating these is appealing.

Thanks!

Hi, I wish it was something I could generate. Unfortunately this is done manually.
I've set it up in this specific way so that people, who are new to Nix, have an easier time navigating through all the directories and references.

You could use a package like tree to do this, but this will still give you a bit of work to get it the same way since it also give all the unreferenced files.
I guess this can be customized more with options but a basic example: echo -e "$(tree)\n$(cat file)" > file.

If you are just interested in this because the ease of navigating inside your project, you can also just use an editor that supports GoTo with relative paths. So you can just click or select the imported paths. Personally I use an lsp called nil, that does the job for me in Emacs.

Imo it can be done by some vim autocmds and bash script.

I'm sure you can, but in my opinion the time spend tweaking these manually at sporadic intervals will be much less then spending time automating this trivial task.

Closing this for now. If someone makes such script, feel free to share.