-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
treewide: Modular setup hooks #40139
treewide: Modular setup hooks #40139
Conversation
export NIX_${role}LDFLAGS+=" -liconv" | ||
} | ||
|
||
addEnvHooks "$hostOffset" iconvLdflags |
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.
So were addEnvHooks ever needed here? I was not really sure what they were doing but it was used in many places.
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.
Nope! and env hook does something per dependency. It's a way to accumulate a bunch of things which are for-eached at the end. Basically, If your hook doesn't use $1
, it shouldn't be an env hook.
@@ -300,7 +305,7 @@ stdenv.mkDerivation { | |||
|
|||
inherit dynamicLinker expand-response-params; | |||
|
|||
# for substitution in utils.sh | |||
# for substitution in utils.bash |
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.
What is making these bash scripts? I know we have in the past assumed bash - but it seemed nice to make these in theory work on non-Bash shells.
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.
Virtually all our stuff is bash-only. Given we're not on MS-DOS with max-3 file extensions, I figure it's best to be honest on use .bash
not .sh
:D. More seriously, editors highlight better with .bash
: emacs will at least check the shebang, but many of these hook files don't have one.
Also fix some setup hooks that unnecessarily used environment hooks, which revolted in the same variable being modified too many times.
ba95564
to
8b0fce8
Compare
I think you have the wrong number there. |
fixed: #40046 |
|
||
setupHooks = [ | ||
../setup-hooks/role.bash | ||
./setup-hook.sh |
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.
Could we just source this in the setup-hook.sh? That would mean we shouldn't need to add the setupHooks logic (yet).
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.
@matthewbauer well it still needs to be part of the derivation closure which means extra hoops anyways.
Awesome work! |
Success on x86_64-linux (full log) Attempted: stdenv Partial log (click to expand)
|
Also might want to look to see if this fixes #40013. We also have a hack for inkscape having long args in a276d51...047c937 that may no longer be needed. |
Failure on x86_64-darwin (full log) Attempted: stdenv Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: stdenv Partial log (click to expand)
|
@Ericson2314 https://hydra.nixos.org/build/74502711/nixlog/1
Not sure if it's since been fixed or not. |
Fixes issue from PR #40139.
Hopefully fixed in 89e196d. |
return 1 | ||
;; | ||
esac | ||
|
||
content="${content//"$pattern"/$replacement}" | ||
eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' |
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.
What’s this commit do? Such major changes to the internals of stdenv
should at least have an extensive commit message of all the implications. I’m told substituteInPlace
is very slow (in the order of seconds), so on inquiring this is the last commit that popped up, with no commit description whatsoever. :(
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.
Maybe it was slow before, but eval
ing is a strong contender. This line should have a comment why it is necessary.
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.
Was this resolved? Does this still have a performance problem? (If so, is there a known way to reproduce it?)
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.
To reproduce it, try changing something in pkgs/development/tools/build-managers/bazel/default.nix
and then run nix-build -A bazel /path/to/nixpkgs
.
You should see that the substitution of every file takes like half a second, which is a lot for a simple text substitution.
See also #35304 (comment), cc @mboes
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.
It's always been O(size of file * number of @var@ definitions), which is quiet shitty.
Just as we did for "expand response params", we should probably rewrite this in C or something.
I'm not seeing 0.5s locally, but it sure does add up!
As a workaround for this particular case,
I looked into it a bit and put together this workaround:
dtzWill@9ed2c64
LMK if this looks good (dunno if it's any trouble to try it),
if so we can submit a PR with it.
…On Wed, 02 Jan 2019 08:15:20 -0800, Profpatsch ***@***.***> wrote:
Profpatsch commented on this pull request.
> return 1
;;
esac
- content="${content//"$pattern"/$replacement}"
+ eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'
To reproduce it, try changing something in `pkgs/development/tools/build-managers/bazel/default.nix` and then run `nix-build -A bazel /path/to/nixpkgs`.
You should see that the substitution of every file takes like half a second, which is a lot for a simple text substitution.
See also #35304 (comment), cc @mboes
--
You are receiving this because your review was requested.
Reply to this email directly or view it on GitHub:
#40139 (comment) part: text/html
|
Motivation for this change
It's error prone to copy paste this "role" stuff everywhere. Also, the more similar the
*-wrapper
s are, the easier it will be add apkgconfig-wrapper
as @bgamari once mentioned needing. Also some of the env hooks should just be setup hooks (setup hooks directly rather than setup hooks that define env hooks).I don't really like this
setupHooks
bloat, but after #31414 we can just make these helper setup hooks dependencies, which will work fine. I'd have loved to land that PR first, but fixing it requires #26004 which would be easier (but still hard) with this, so I do this stop-gap first.Fixes #40046
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)