jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.84k stars 188 forks source link

[nix] Build all packages in same nix command #2032

Closed mikeland73 closed 2 months ago

mikeland73 commented 2 months ago

Summary

This changes how installNixPackagesToStore calls nix.Build so that it installs all installables in same nix command.

It does this by grouping all installables into two groups, one for allow-insecure and other for default and runs build on both groups (if not empty)

I was able to remove packageInstallErrorHandler because it is already called in packagesToInstallInStore so we will never actually try to build something that can't build on the system, or if it requires --allow-insecure we will notice it then.

This does change our segment logging to group packages together for install times, so we will need to do some more work on the metrics side to determine slow packages.

How was it tested?

savil commented 2 months ago

For the scenario where a user clones a repo and does devbox install, this PR's change will mean they have to wait a long time without much UI information about what is being installed. What does the UX look like?

Alternatively, we could preserve the old-behavior that prints output for each package, while having a --parallel flag or DEVBOX_INSTALL_PARALLEL env-var setting that runs it in parallel. EDIT: "parallel" is incorrect. Maybe "--bulk" or something? not sure.

mikeland73 commented 2 months ago

@savil like @gcurtis mentioned, this does show output the entire time.

One thing this removed is the package by package manual output we used to do, specifically fmt.Sprintf("[%d/%d] %s", stepNum, total, pkg)

in it's place we now do:

ux.Finfo(
        d.stderr,
        "Installing the following packages to the nix store: %s\n",
        strings.Join(packageNames, ", "),
    )
sentry-io[bot] commented 2 months ago

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎