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

builder: split nix-instantiate & nix-build #117

Merged
merged 12 commits into from
Oct 18, 2019

Conversation

Profpatsch
Copy link
Collaborator

@Profpatsch Profpatsch commented Jul 25, 2019

A bit of refactoring, to finally split the instantiation and build (see last commit).

Please review commit-by-commit.

  • Add wrappers around PathBuf to distinguish drv files and final build results
  • Use struct OutputPaths to keep results of logged-evalatuion.nix & move errors from use time to parse time
  • remove lorri shell
  • Fix an issue with nix output parsing
  • and finally split instantiate and build

(Part of the fix for #58)

Closes #143
Closes #50

@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch from 498e81f to 252d0e7 Compare August 1, 2019 10:33
src/nix.rs Outdated
attribute: Option<String>,
result_gc_root_path: Option<PathBuf>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Right off the bat feedback: this isn't workable. We need to GC root everything Nix evaluates and builds, and enforce it at the type system level.

One improvement on the way it works on master is if a store path result from the Nix evaluator carries with it its tempdir handle, forcing the tempdir to stay alive until the Nix value is garbage collected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, what effectively happened is: Once I removed the lorri shell subcommand, no code whatsoever is using this stuff anymore. The only part that creates a gc root is the store path generated by logged-evaluation.nix, and that is handled by roots. I’m thinking about completely removing this from the builder for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, the problem with creating the roots after a build is that there is a small period of time (race condition) where a GC could delete the store path. Thus we must pass the gc root to the nix build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is resolved by basing this branch on #131. PTAL

@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch 4 times, most recently from 64a980a to 07e4e96 Compare August 8, 2019 14:17
@Profpatsch Profpatsch changed the title WIP Builder add transitive source detection tests builder: split nix-instantiate & nix-build Aug 8, 2019
@Profpatsch Profpatsch marked this pull request as ready for review August 8, 2019 14:22
@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch from 07e4e96 to c712e01 Compare August 8, 2019 14:24
@Profpatsch
Copy link
Collaborator Author

Rebased & ready for review.

@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch from e285e19 to a54af4a Compare August 9, 2019 12:28
@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch 2 times, most recently from b279440 to 4e020e5 Compare August 13, 2019 17:10
@Profpatsch Profpatsch requested a review from grahamc August 13, 2019 17:13
@Profpatsch
Copy link
Collaborator Author

I split this PR up in multiple PRs for easier review:

And the rest of the commits are in this PR.

@grahamc grahamc added the P1 critical: next release label Aug 14, 2019
@Profpatsch Profpatsch changed the base branch from master to builder-use-OutputPaths-for-root-names August 16, 2019 16:21
@grahamc grahamc force-pushed the builder-use-OutputPaths-for-root-names branch from 630502b to 27afeba Compare August 20, 2019 16:30
@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch from 65cb5b9 to a7e1184 Compare August 28, 2019 15:43
@Profpatsch Profpatsch force-pushed the builder-use-OutputPaths-for-root-names branch from 27afeba to c576b95 Compare August 28, 2019 15:45
@grahamc grahamc force-pushed the builder-add-transitive-source-detection-tests branch from a7e1184 to 5292d7e Compare August 29, 2019 14:44
@grahamc grahamc force-pushed the builder-use-OutputPaths-for-root-names branch 3 times, most recently from 26543c5 to 90aebe2 Compare August 29, 2019 15:22
@grahamc grahamc force-pushed the builder-add-transitive-source-detection-tests branch 2 times, most recently from eccd66f to ab6535e Compare September 23, 2019 19:25
@grahamc grahamc changed the base branch from builder-use-OutputPaths-for-root-names to master September 23, 2019 19:25
@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch from 24d0305 to 8ae8699 Compare October 4, 2019 18:33
@Profpatsch Profpatsch changed the base branch from master to builder-default.nix-logic October 4, 2019 18:34
@Profpatsch Profpatsch force-pushed the builder-default.nix-logic branch from 1f73f45 to fa64be3 Compare October 7, 2019 13:43
@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch from 8ae8699 to fc9141a Compare October 7, 2019 13:58
@Profpatsch Profpatsch force-pushed the builder-default.nix-logic branch from fa64be3 to e7acd51 Compare October 7, 2019 14:01
@grahamc grahamc changed the base branch from builder-default.nix-logic to master October 7, 2019 16:20
@Profpatsch Profpatsch force-pushed the builder-add-transitive-source-detection-tests branch from fc9141a to a37fd0a Compare October 7, 2019 16:21
grahamc and others added 5 commits October 16, 2019 12:40
The build is split into a two-step process:
- nix-instantiate, which is called with -vv and parses its stderr (and
  produces drv files)
- nix-build, which builds the drv file

The idea behind this is that we can’t easily write tests which use
`nix-build` (nix-in-nix problem), so we are only gonna use the first
step for tests (which is enough to check the stderr parsing stuff).

Another problem this solves is that the stderr of nix-build is now
separated from the stderr of nix-instantiate, and nix-build is not
called with -vv, meaning we can show it to the user while it’s
generated, making it possible to fix the silence problem lorri has.

Closes #126
lorri would crash if the instantiation works but the build has an
error; because we didn’t convert the build errors into
`Info::Success`.

Closes #121
We don’t capture the build output of nix-build at the moment, so let’s
use `nix-store --read-log` to check whether the non-utf8 sequence is
there.
@grahamc grahamc force-pushed the builder-add-transitive-source-detection-tests branch from a37fd0a to f57b79b Compare October 16, 2019 16:40
grahamc and others added 7 commits October 18, 2019 13:41
The older version of Nix on darwin (2.0) had a bug where it wouldn't
interpret a symlink as a `.drv`.

The upstream Travis support for newer Nixes on Darwin is a bit broken,
so this is working around that for now.

The default language changes to `minimal`, but the Linux version
overrides it to `nix`.
@grahamc grahamc merged commit f20a323 into master Oct 18, 2019
@Profpatsch
Copy link
Collaborator Author

holy cow, I can’t believe it’s merged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 critical: next release
Projects
None yet
2 participants