New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/activation: Identifies the snippet that failed #44526
nixos/activation: Identifies the snippet that failed #44526
Conversation
This allows a developer to better identify in which snippet the failure happened. Furthermore, users seeking help will have more information available about the failure.
6b75282
to
6a25a35
Compare
Alternate suggestion for the output-to-snippet mapping: Prepend the snippet name to every message:
|
Unless I'm mistaken, this is hard to do right within bash. One of the issue is the way stdin and stderr will be interleaved, without guarantee about there being a newline! Though I must say, it would look fine if it was implemented that way. |
@samueldr Interesting approach! Home Manager prints a line for each entered activation script block and I find it a bit too chatty. I might adopt this method to only print the failing block unless verbose output is enabled 🙂 |
Do you know any equivalent where we could activate the chatty version for the activation script? |
@samueldr In Home Manager the "chatty" version is the default and there isn't really a non-chatty option. My idea would be to have the default be non-chatty (i.e. only print the failing block) and have the chatty one when using the So, currently I get the output
by default but would instead get
|
So uh, any reviews, updates? @edolstra, any reasons this shouldn't be merged? (Singling you out since I'd like someone with stage-1/activation background to agree or disagree) Others fitting the bill, feel free to chime in. |
This looks good to me, but the proposal to spam the console with dozens of activation script names is definitely not a good idea, under the principle that programs should be quiet unless they have something interesting to say. |
Yes, the proposal was conditional to there being a way to opt-in to a verbose mode; which there isn't. |
I have amended the description... What wat previously in the description was a small request for comments: This, though feels a bit barren. It would be nice if there was some other mechanisms allowing to match the start of the output to the specific snippet, and not only the failure state. For that, I had something like what follows in mind, though it causes a very verbose output (which, too, follows). diff --git a/nixos/modules/system/activation/activation-script.nix b/nixos/modules/system/activation/activation-script.nix
index 1058b212b7a..d632b20e930 100644
--- a/nixos/modules/system/activation/activation-script.nix
+++ b/nixos/modules/system/activation/activation-script.nix
@@ -8,6 +8,7 @@ let
addAttributeName = mapAttrs (a: v: v // {
text = ''
#### Activation script snippet ${a}:
+ printf " -> '%s'\n" "${a}"
_localstatus=0
${v.text}
Suggestions welcome. |
I like the more verbose output, but maybe it'd be tolerable if it was one line:
which was appended to until done. |
This allows a developer to better identify in which snippet the
failure happened. Furthermore, users seeking help will have more
information available about the failure.
Motivation for this change
Talked about the idea briefly earlier today on #nixos
EDIT Removed a misleading request for comments, see later comment form myself
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)