Skip to content
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

nixstore: add package for querying and resolving Nix store paths #884

Merged
merged 4 commits into from
Apr 11, 2023

Conversation

gcurtis
Copy link
Collaborator

@gcurtis gcurtis commented Apr 10, 2023

Given the store name of a Nix package, a nixstore.Root can return a slice of transitive package dependencies in topological order without invoking a separate Nix process. This builds on top of the code from c009546.

Once we have a search index of attribute paths to store paths, this will allow Devbox to bypass nixpkgs evaluation by resolving and installing packages directly.

Follow-up improvements:

  • Cache resolved package dependencies so that they don't need to be recomputed every time.
  • Support for resolving dependencies using .narinfo files.

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!

I'm not sure I'll be much help reviewing the actual implementation (without spending additional time to learn a lot of it myself), but the idea and structure look good.

I think if there are a few low hanging possible unit tests or integration tests that would be pretty nice (e.g. install some stuff with devbox and then use this to retrieve a package and dependencies)


// TopologicalSort resolves the dependency tree for a package and returns it as
// a slice of packages in topological order.
func TopologicalSort(pkg *Package) []*Package {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't export

Copy link
Contributor

Choose a reason for hiding this comment

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

put sort functions into own file.

Given the store name of a Nix package, a `nixstore.Root` can return a
slice of transitive package dependencies in topological order without
invoking a separate Nix process. This builds on top of the code from
c009546.

Once we have a search index of attribute paths to store paths, this
will allow Devbox to bypass nixpkgs evaluation by resolving and
installing packages directly.

Follow-up improvements:

- Cache resolved package dependencies so that they don't need to be
  recomputed every time.
- Support for resolving dependencies using .narinfo files.
@gcurtis gcurtis merged commit 4f4e953 into main Apr 11, 2023
9 checks passed
@gcurtis gcurtis deleted the gcurtis/nixstore branch April 11, 2023 22:55
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.

None yet

2 participants