This is an optionated tool for viewing and editing your nix configuration as a tree
- Note this tool currently is only tested for NixOS, so if you aren't on NixOS use it at your peril!
- To run this program you will need nix flakes enabled (or you can append the option for every command)
- So to enable nix flakes for just your user add this to your home-manager configuration:
nix = {
package = pkgs.nix;
settings.experimental-features = [ "nix-command" "flakes" ];
};
- Or to enable it system wide:
nix.settings.experimental-features = [ "nix-command" "flakes" ];
- Finally, if you just want to enable it on a command-by-command basis append
--experimental-features 'nix-command flakes'
to every command
- The program is wrapped in a flake, so it can be run with:
nix run 'github:max-amb/nix-tree' <your filename>
- There are two options which you can enable when running the program
-w
which will enable writing over of the original file-c
which will enable comments being copied over
- The main screen displaying the tree:
- The screen for generation management:
- The screen you see when you select a variable:
- The screen you see when you select a section:
- Q: Is there a tutorial/guide on how to use the program?
- A: There is help screens on most of the screens which can be accessed by pressing ?.
- Q: How does it actually work?
- A: I have some diagrams in the works currently which will be added in replacement of this answer!
- Q: Who is this aimed at?
- A: This program is mostly aimed at users who are new to nix and would benifit from some guardrails when creating a configuration, however more experienced users still may find it useful for it's simplistic display of the configuration.
- Q: What does opinionated mean?
- A: It means that the program will group all of the related sections together, for example if
services.openssh
andservices.xserver
were seperated in the original configuration, they will be both underservices
in the tree and in the outputted file.
- A: It means that the program will group all of the related sections together, for example if
- Q: Why is comments not on by default?
- A: The program doesn't copy over all of the comments to the new file, comments that are not obviously attached to a line of code are not copied over. Hence, it is simpler to require the user to enable comment copying as it leads to less confusion.
- More safety rails for the user, e.g. more pattern matching in inputs
- Complete support of the basic Nix language
- The ability to analyse flakes (e.g.
in
statements)
This program obviously is not perfect, hence there are some limitations that should be taken into account by the user:
- The program cannot currently parse the
let in
combination or any flake for that matter - It may not be able to handle multiline strings often found in
extraConfig
options