`nix edit` for nixpkgs modules?

My current workflow for checking out how nixpkgs modules (stuff enabled via services.foo.enable etc.) implement service settings is to look them up on search.nixos.org and from there view the source on github. I like being able to look up the options via man configuration.nix in my terminal and would like to do the same for module source. I know that you can do nix edit nixpkgs#foo but haven’t been able to intuit if this is possible to do for modules as well. Can nix edit do this or is it strictly for packages?

NixOS used to ship with a tool nixos-option. That doesn’t appear to be enabled by default anymore, probably because IIRC it never got updated to support flakes. In the meantime, for basic options you can do something like nix eval flake#nixosConfigurations.myhostname.options.programs.tmux.enable.declarations to get a list of files that declare the option (and files to find out where value definitions are). If the option you want is in a submodule it gets a lot more complicated though.

2 Likes