nh hides activation logs
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'
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.
Activation scripts are absolutely atrocious.
Very very true 😅
Keep us posted if you want to have feedback about it.
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.
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.
I noticed that unfortunately hm activation errors are also hidden, see:
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
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.
I was bitten by this (in my case a file needed backup) can you guys make it so -vv also forwards the activation log?
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.
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.
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.
I'll try to make it a little more generic and support it across platforms.
#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.