-
Notifications
You must be signed in to change notification settings - Fork 80
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
Create module extensions #183
Comments
This is somewhat related to #49 which proposes a way to generated separate |
I'm interested to start working on this. |
@tshaynik Thank you, that would be a valuable contribution. The upcoming Bazel 6 release is targeted to use bzlmod by default, so it would be good to have bzlmod support for rules_nixpkgs soon. The wider context in #181 will probably also be useful for this task. |
Hi folks, sorry to chime in, just a question regarding this, as I'd love to start using I currently don't see a way to import a package from a local rules_nixpkgs/core/nixpkgs.bzl Line 813 in 9b13ed0
Alternatively, is it possible to mix both |
Thanks for reaching out @ar3s3ru! Flake support is also planned but tracked in #348. Yes, it's possible to mix |
Related to #181
Is your feature request related to a problem? Please describe.
The new bzlmod dependency management system introduces a new concept called module extensions.
rules_nixpkgs
currently only exposes repository rules. To fully "modularize"rules_nixpkgs
we need to expose the same functionality that is currently exposed as repository rules in the form of module extensions.Describe the solution you'd like
Bazel's repository rules are evaluated individually. I.e. each
nixpkgs_package
is evaluated separately and creates its own external repository. Module extensions on the other hand are evaluated collectively. Each invocation across allMODULE.bazel
files in a given project and its transitive dependencies generates a tag with some metadata. In the end the corresponding module extension is evaluated with all these tags as inputs and can then use this information and invoke external tools to generate repository rule invocations to import all required external dependencies.A direct translation of the current repository rules into a module extension could look something like this on the use-site:
Note, the above is only a sketch and may not be possible in exactly that form.
Describe alternatives you've considered
The sketch above is a direct translation of the features provided by
rules_nipxkgs
right now. However, due to the collective evaluation of module extensions with bzlmod, we could go further and also import transitive Nix dependencies into Bazel in a way that handles overlapping dependency graphs correctly. E.g. if a project imports two C librarieslibA
andlibB
fromnixpkgs
and both of these libraries depend onlibC
, then the module extension could generate imports of all threelibA
,libB
, andlibC
and expose the dependency graph to Bazel. E.g.Again, the above is only a sketch and may not be possible in exactly that form.
However, I would propose to start with a direct translation and consider something more elaborate like the above as a later extension.
Additional context
The design document in the section "Design: Module rules and non-Bazel registries" explains module extensions in more detail.
Tasks
nix_repo
to import Nix repositoriesdefault
to use a global default repogithub
to import a Github repositoryhttp
to download a repositoryfile
to import from a local fileexpr
to import from a Nix expressionoverride
to override a global default reponixopts
nix_pkg
to import Nix packagesattr
to use a globally unified Nix attribute pathlocal_attr
to import a Nix package by attribute path locallylocal_file
to import from a Nix file locallylocal_expr
to import from a Nix expression locallynix_pkg
and hub repo accessornix_pkg
(same fornix_repo
).Tasks
The text was updated successfully, but these errors were encountered: