Skip to content

devbox add fallthrough and fallback for packages not handled by search #1264

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

Merged
merged 3 commits into from
Jul 11, 2023

Conversation

LucilleH
Copy link
Collaborator

@LucilleH LucilleH commented Jul 10, 2023

Summary

devbox add fallthrough and fallback for packages not handled by search.

This PR does not do the following:

  1. Print a warning that a package is in a fallthrough case (I'm unclear if a warning is needed?)
  2. Accept an alternative nixpkg commit hash for that specific package (I'm unclear if we are deprecating nixpkg commit field in devbox.json immediately?)

I'd like to address those two things above if needed in a separate PR as a follow up.

Example lockfile:

{
  "lockfile_version": "1",
  "packages": {
    "python310": {
      "plugin_version": "0.0.1",
      "resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#python310",
      "source": "nixpkg"
    },
    "python310Packages.pip@latest": {
      "last_modified": "2023-05-06T16:57:53Z",
      "plugin_version": "0.0.1",
      "resolved": "github:NixOS/nixpkgs/16b3b0c53b1ee8936739f8c588544e7fcec3fc60#python310Packages.pip",
      "source": "devbox-search",
      "version": "23.0.1"
    },
    "stdenv.cc.cc.lib": {
      "resolved": "github:NixOS/nixpkgs/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62#stdenv.cc.cc.lib",
      "source": "nixpkg"
    }
  }
}

How was it tested?

In the Tensorflow example:

devbox add stdenv.cc.cc.lib
devbox add nodejs-16_x
devbox update

@LucilleH LucilleH requested review from mikeland73 and Lagoja July 10, 2023 22:23
Copy link
Contributor

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

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

This is a great and simple start, but I think there a few issues we may need to solve before we merge (or ship?)

  • Adding fall-through package causes the warning Warning: Your devbox.json contains packages in legacy format. Please run devbox update to update your devbox.json. to be shown on subsequent commands.
  • Running devbox update will add @latest to the packages in devbox.json which will cause them to fail on the next run/shell. (Adding @latest was our upgrade path for old configs)

Possible solution:

  • Add "source" field to lock file packages. Source can be devbox-search, nixpkgs. etc. Only show legacy warning is source if unknown and package is in legacy format.
  • When doing devbox update don't update stuff with nixpkgs source. If lockfile/source is missing then check if package exists in search before appending the @latest.

@LucilleH LucilleH requested a review from mikeland73 July 11, 2023 00:45
@LucilleH LucilleH force-pushed the lucille--nixpkg-fallback branch from 50b7687 to 6c60238 Compare July 11, 2023 00:47
@LucilleH LucilleH force-pushed the lucille--nixpkg-fallback branch from 6c60238 to fca5809 Compare July 11, 2023 00:53
Copy link
Contributor

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

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

Nice! This is super clean

@@ -403,7 +403,7 @@ func (p *Package) Versioned() string {
}

func (p *Package) IsLegacy() bool {
return p.isDevboxPackage() && !p.isVersioned()
return p.isDevboxPackage() && !p.isVersioned() && p.lockfile.Source(p.Raw) == ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Another possible API could be

p.lockfile.Get(p.Raw).Source() to have lock packages themselves respond to source()

(and just default Source() to be empty string if not set or if package is nil)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I like p.lockfile.Get(p.Raw).Source() better. I'll follow up with a separate PR

@LucilleH LucilleH merged commit f6f94fe into main Jul 11, 2023
@LucilleH LucilleH deleted the lucille--nixpkg-fallback branch July 11, 2023 15:50
LucilleH added a commit that referenced this pull request Jul 11, 2023
## Summary
Update lockfile api for package source as suggested in
#1264 (comment)

## How was it tested?
devbox run build
devbox update
mikeland73 added a commit that referenced this pull request Sep 8, 2023
…1463)

## Summary

Restores functionality implemented by
#1264 and refactored in
#1279

which was accidentally broken by
#1437

tldr: the `FillNarInfoCache` function breaks if packages are not in
search, but we support non-search packages via fallback (.e.g.
stdenv.cc.cc.lib)

I'm keeping surface area as small as possible, but as a follow up I
think we can remove the `devpkg.FillNarInfoCache` calls from `impl.Add`
if we simply ignore the`IsInBinaryCache` errors in
[ValidateExists](https://github.com/jetpack-io/devbox/blob/main/internal/devpkg/validation.go#L10-L26)
or remove `IsInBinaryCache` from that function completely (I'm not
convinced it is needed, @savil @ipince correct me if I'm wrong)

## How was it tested?
`devbox add stdenv.cc.cc.lib`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants