-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
nix-output-monitor: Add nom-build script #114903
Conversation
I am torn on the question if this is something I should put in the upstream repository. But patching the paths will be at least the same number of lines here in post-install, so I don‘t see a big benefit. |
@@ -25,6 +26,10 @@ mkDerivation { | |||
ansi-terminal async attoparsec base containers directory HUnit mtl | |||
nix-derivation process relude stm text time unix | |||
]; | |||
postInstall = '' | |||
echo -e "#!/bin/sh\n${expect}/bin/unbuffer nix-build \"\$@\" 2>&1 | exec $out/bin/nom" > $out/bin/nom-build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo -e "#!/bin/sh\n${expect}/bin/unbuffer nix-build \"\$@\" 2>&1 | exec $out/bin/nom" > $out/bin/nom-build | |
echo -e "#!/bin/sh | |
${expect}/bin/unbuffer nix-build \"\$@\" |& $out/bin/nom | |
" > $out/bin/nom-build |
Why do we want exec here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk, I don‘t know of a disadvantage and I don‘t see that we need the running bash process after nom has been started. Also maybe exit code propagation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exec
is really just to get rid of the bash process, there’s no reason to keep it around. It also will keep the ps
output cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably also be a bit cleaner if written using a here-doc. At a bare minimum, I don’t see why this is using the -e
flag to echo
. And the shebang should probably be #!${runtimeShell}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heck, you could probably make this a writeShellScript
instead, using the outPath
attribute of the resulting derivation, like
let
nom-build = writeShellScript "nom-build" ''
${expect}/bin/unbuffer nix-build "$@" |& ${self}/bin/nom
'';
self = mkDerivation rec {
# …
postInstall = ''
install -Dm755 ${nom-build} $out/bin/nom-build
'';
};
in self
I haven’t tried this directly myself, but I think the outPath
is available without forcing anything beyond name
and fixed-hash attrs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If thought about that, but was un-optimistic. I’ll try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that doesn‘t make sense. If the hash of nom changed the hash of nom-build needs to change and vice versa. I‘ll try anyways just to make sure, but I would be thoroughly surprised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I have rewritten the function with your hints. Looks much better now.
Now we need bash-completion for nom-build. |
Fair enough. But I have no clue how to do that … |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/announcing-the-nix-output-monitor/11672/7 |
Motivation for this change
By popular demand we present
nom-build
it's exactly likenix-build
but with morenom
.Credits to @lilyball for the idea:
https://discourse.nixos.org/t/announcing-the-nix-output-monitor/11672/6
My bash in nixpkgs foo is not very strong, so I appreciate any style critique.
\cc @mweinelt
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)