Skip to content

A tool for viewing and editing your nix configuration as a tree

License

Notifications You must be signed in to change notification settings

max-amb/nix-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nix-tree

This is an optionated tool for viewing and editing your nix configuration as a tree

RUN 🏃

  • Note this tool currently is only tested for NixOS, so if you aren't on NixOS use it at your peril!

Enabling flakes ❄️

  • 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

Building and running the program 👷

  • 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

Screenshots 📸

  • The main screen displaying the tree: Tree screen
  • The screen for generation management: Generation management screen
  • The screen you see when you select a variable: Variable screen
  • The screen you see when you select a section: Section screen

FAQ ❓

  • 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 and services.xserver were seperated in the original configuration, they will be both under services in the tree and in the outputted file.
  • 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.

To be implemented in the future⏭️

  • 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.instatements)

Limitations

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

About

A tool for viewing and editing your nix configuration as a tree

Topics

Resources

License

Stars

Watchers

Forks