-
Notifications
You must be signed in to change notification settings - Fork 69
Conversation
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.
Great Scott!
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.
Very cool!
Only a few things I noticed.
How long do we want to keep the v1
code around?
Can we squash the fixup commits before merging?
|
||
# effectfully accept the new variable's contents | ||
export "$@"; | ||
export "${@?}"; |
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.
Is ${var?}
the same as ${var:?}
?
Hmm... not sure :) maybe until it is annoying?
Yep! that is why I marked which commit they should be squashed in to. A few more commits are push ed for you to review, once I get a +1 I'll squash |
To match what upstream does: https://github.com/NixOS/nixpkgs/blob/e13808f6dee2d4538cfecb15636256d6703b9fc1/pkgs/stdenv/generic/setup.sh#L176-L189 via https://github.com/NixOS/nixpkgs/blob/e13808f6dee2d4538cfecb15636256d6703b9fc1/pkgs/development/compilers/go/setup-hook.sh#L1-L3 It is possible we have a hint here: adding some magic to addToSearchPath might be an effective way to detect and handle these scenarios.
…tead of in the output directly.
…t Go and other tooling uses to append tools to the environment variables
… parameters so we can reconstruct it in the envrc.bash
…sn't have that scoping anyway
…y at the name, vs. a subdirectory
…ypes with shared code
Variable values can contain essentially anything *but* a null byte. This means a delimeter could also use anything but a null byte, and that our format is invalid. Switching to null bytes makes the format safe for even the wackiest of delimeted values.
This PR adds support for the logged evaluation runner to call setup hooks, and preserve their environment. It is a bit weird as it makes some assumptions about how Nixpkgs works -- but it does work. There is cleanup, documentation, and testing to be done, but give it a go. But maybe don't review the code yet.
The key insight which drove the authoring of this PR was that setupHooks often call
addToSearchPathWithCustomDelimiter
which very closely mirrors what the direnv hook was doing anyway. This PR overrides that function inside the environment build and captures the parameters, so the direnv hook can append the variable.