What is your approach to easily examining the result of your home-manager config?

I was thinking about my recent response to this reddit thread about shortening the feedback loops when iterating on nix configs, and it made me wonder about others’ approaches to looking at the result of a home-manager-derived config file.

I’m often iterating on the nix aspects of a config file and debugging why it isn’t producing the expected output. The issue with hm is – if one doesn’t want to go through a full activation – the resulting config file in question is often buried several symlinks and activation scripts deep in the result.

In my case, I use the below alias (others would obviously need to change the activation-username part)

show-hm-generation = ''grep -o '/nix/store/.*-home-manager-generation' "$(grep -o '/nix/store/.*/activate' "$(grep -o '/nix/store/.*-activation-n8henrie$' ./result/activate)")"''; 

It makes it pretty quick to nixos-rebuild build and then show-hm-generation, or ls $(show-hm-generation)/home-files (often ctrlmetae to expand to the actual path prior to running to make follow-ups and use tab completion easier).

What other approaches are people using?

I just use the repl.

nix repl
> :lf .
> :p homeConfigurations.kyle.config.some.setting.attrset

Comes with the lazy evaluator so it’s decently faster than parsing the build.

I definitely use the repl, but in this case I mean for debugging the translation between nix and the actual config file (iow what I have in nix is syntactically valid, but not giving me the desired output – often things like quoting issues, or perhaps the depth of a submodule isn’t translating to the right yaml, that kind of thing).

The repl can do that, take ~/.config/mako/config as a concrete example:

:p homeConfigurations.kyle.config.xdg.configFile."mako/config".text

(edit, reload with :r, repeat)

1 Like

Fair – in this case I’m trying to debug my ssh config; programs.ssh doesn’t expose a .text, nor do I see .ssh in builtins.attrNames darwinConfigurations.natepro.config.home-manager.users.n8henrie.xdg.configFile (EDIT: obv ~/.ssh is not in ~/.config, so wouldn’t been in xdg configFiles). How would you debug in this case?

EDIT: Looks like it should be in home.file, let me look again…

EDIT2: Sure is! The extra leading dot threw me off. :p darwinConfigurations.natepro.config.home-manager.users.n8henrie.home.file.".ssh/config".text.

Thanks @dsparby!

Sorry I should have been more specific with an example.

No need to apologize, I appreciate you taking the time to respond in the first place.

1 Like