Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Fix #23: Call setup hooks (WIP) #75

Merged
merged 24 commits into from
Jun 5, 2019
Merged

Fix #23: Call setup hooks (WIP) #75

merged 24 commits into from
Jun 5, 2019

Conversation

grahamc
Copy link
Contributor

@grahamc grahamc commented May 9, 2019

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.

Copy link
Collaborator

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Scott!

src/logged-evaluation.nix Outdated Show resolved Hide resolved
src/logged-evaluation.nix Show resolved Hide resolved
src/logged-evaluation.nix Show resolved Hide resolved
src/logged-evaluation.nix Outdated Show resolved Hide resolved
src/logged-evaluation.nix Outdated Show resolved Hide resolved
src/ops/direnv/envrc.bash Outdated Show resolved Hide resolved
src/ops/direnv/envrc.bash Outdated Show resolved Hide resolved
envrc-tests/test.sh Outdated Show resolved Hide resolved
envrc-tests/test.sh Outdated Show resolved Hide resolved
nix/bogus-nixpkgs/builder.sh Show resolved Hide resolved
Copy link
Collaborator

@Profpatsch Profpatsch left a 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 "${@?}";
Copy link
Collaborator

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:?}?

src/logged-evaluation.nix Show resolved Hide resolved
tests/integration/envrctestcase.rs Outdated Show resolved Hide resolved
tests/integration/envrctestcase.rs Show resolved Hide resolved
src/ops/direnv/envrc.bash Show resolved Hide resolved
@grahamc
Copy link
Contributor Author

grahamc commented Jun 5, 2019

How long do we want to keep the v1 code around?

Hmm... not sure :) maybe until it is annoying?

Can we squash the fixup commits before merging?

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

grahamc added 15 commits June 5, 2019 15:50
…t Go and other tooling uses to append tools to the environment variables
… parameters so we can reconstruct it in the envrc.bash
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.
@grahamc grahamc merged commit b42af3c into master Jun 5, 2019
@grahamc grahamc deleted the bug23-setuphook branch June 5, 2019 20:24
This was referenced Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants