nh icon indicating copy to clipboard operation
nh copied to clipboard

nh hides activation logs

Open DerRockWolf opened this issue 3 months ago • 8 comments

To be fair, most of them are not interesting to me, but some of them are.

My main use-case is logging something in the onFilesChange activation to inform me that some manual thing should be done.

Example:

Details

home-manager:

Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating linkGeneration
Cleaning up orphan links from /home/kai
Creating home file links in /home/kai
Activating batCache
No themes were found in '/home/kai/.config/bat/themes', using the default set
Writing theme set to /home/kai/.cache/bat/themes.bin ... okay
Writing syntax set to /home/kai/.cache/bat/syntaxes.bin ... okay
Writing metadata to folder /home/kai/.cache/bat ... okay
Activating installPackages
nix profile remove /nix/store/k087awigqdn459f2irbnxg6a3js5lncp-home-manager-path
removing 'home-manager-path'
Activating dconfSettings
Activating krew
reading krewfile
getting installed indexes
updating krew
getting installed plugins
Activating onFilesChange
Arkenfox version changed! Please run "cd /home/kai/.mozilla/firefox/main && ./prefsCleaner.sh"
Activating reloadSystemd
Starting units: agenix.service

nh:

> Activating configuration
nix profile remove /nix/store/k087awigqdn459f2irbnxg6a3js5lncp-home-manager-path
removing 'home-manager-path'

DerRockWolf avatar Aug 17 '25 13:08 DerRockWolf

Frankly I consider this a feature of nh. Activation scripts are absolutely atrocious.

Though I was working on this recently. Might add something to allow displaying such logs in commands in the near future, before 4.2 is released.

NotAShelf avatar Aug 17 '25 13:08 NotAShelf

Activation scripts are absolutely atrocious.

Very very true 😅

Keep us posted if you want to have feedback about it.

DerRockWolf avatar Aug 17 '25 13:08 DerRockWolf

I also faced this. Spent some time trying to understand why nh says

Closure size: 1281 -> 1991 (1937 paths added, 1227 paths removed, delta +710, disk usage +3.3GiB).
> Activating configuration

and successfully exits, but the configuration doesn't actually get applied. Turns out the activation script threw an error but nh hid it.

magistau avatar Aug 17 '25 17:08 magistau

The problem with error propagation has been fixed in current master. Please try getting nh from the source and see if the issue persists.

I'll see what I can do about hidden activation logs once I have some more time. My current idea is to hide show them by default and add a flag. Maybe it's more reasonablee to tie it to the verbosity level though, haven't decided on it yet.

NotAShelf avatar Aug 17 '25 20:08 NotAShelf

I noticed that unfortunately hm activation errors are also hidden, see:

Image

It just tells that an error during activation has happened. I have to search for it using journalctl -u home-manager-mloeper.service though.

Edit: I just checked the following issue where it says that 4.2.0 should fix it. However, I realized that I am running nixos unstable with nh version 4.2.0 installed: https://github.com/nix-community/nh/issues/437

MartinLoeper avatar Oct 28 '25 23:10 MartinLoeper

It just tells that an error during activation has happened. I have to search for it using journalctl -u home-manager-mloeper.service though.

This is currently intended behaviour. Also not what #437 is about. We propagate exit status, but not the logs (which was not the case before, hence the bug reports from 4.1.1/2). I'm currently experimenting with this, but no promises that I'll add something soon. See my earlier messages for my exact thoughts.

NotAShelf avatar Oct 29 '25 10:10 NotAShelf

I was bitten by this (in my case a file needed backup) can you guys make it so -vv also forwards the activation log?

leiserfg avatar Nov 03 '25 09:11 leiserfg

I'd like to keep verbosity flags exclusive to application logs, and not use them for command forwarding.

Currently workint on a flag to display failed service statuses on rebuild, I'll probably add activation log forwarding with a different flag and make it completely opt-in.

NotAShelf avatar Nov 03 '25 09:11 NotAShelf

This has been implemented in #465 for the os subcommand. In the case of @MartinLoeper this should display the Home Manager service failure if it is installed as a NixOS module.

I'm not yet sure how this should be done for Home Manager and Darwin, because I don't use either of those platforms. If anyone is willing to either share their ideas on how this can be handled (e.g., you use HM standalone or just have a good understanding) or send PRs those would be welcome. Otherwise I'm going to merge #465 and take a look into activation logs for other programs much later. FWIW this is a good start anyway, but I'm hoping not to read the source code of three different tools.

NotAShelf avatar Nov 22 '25 21:11 NotAShelf

For home-manager, most of the time the issue is caused by an error while doing a backup, but nh hides it, making it very hard to debug. I think at least telling "nix log ... to see the full log" will do it.

leiserfg avatar Nov 23 '25 10:11 leiserfg

I'll try to make it a little more generic and support it across platforms.

NotAShelf avatar Nov 23 '25 11:11 NotAShelf

#479 should do the trick. I've did it a bit quick and dirty but I'm mostly positive it'll work as expected on Home Manager and Darwin platforms. Testing would be appreciated.

NotAShelf avatar Nov 23 '25 12:11 NotAShelf