-
Notifications
You must be signed in to change notification settings - Fork 83
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
extract bzlmod
modules for core rules and toolchains
#193
Conversation
dd5bb89
to
f5861e3
Compare
this is in preparation to support `bzlmod`
otherwise the entire file will be consumed as the next line, skipping everything after the last match.
tl;dr: end users of `rules_nixpkgs` should not be affected by this change at all. the additional code is temporary and purely for migration reasons. migrating the go toolchain to `bzlmod` necessitates accessing `rules_nixpkgs_core` as an external repository (later module). therefore we have to incorporate that new repository into the `WORKSPACE` setup. to maintain compatibility with existing installations, `rules_nixpkgs_dependencies()` automatically fetches the new sub-repository from a remote archive. but local testing requires taking it from the working directory! therefore we temporary introduce a `local=` parameter which lets the caller point optionally to a directory for local sub-repositories. the option will be removed when migration to `bzlmod` is complete. it must be configurable, because the call to `local_repository()` takes its path starting from the workspace directory where `rules_nixpkgs_dependencies()` is called: - `bazel test //...` needs `local="."` - `cd examples/toolchains/{go, java, ...}; bazel run :hello` needs `local="../../.."`
no alias for `default_java_toolchain`, since that seems to be used only internally, and a copy of what is usually distributed with Bazel.
leave aliases to existing files to ensure backwards compatibility. put CC toolchain in separate workspace, which is required because `nixpkgs_cc_configure()` references a file `cc.nix` from its own repository, which will be external at the call site.
90ccdc5
to
8dad4fd
Compare
otherwise internal references will break
necessary to facilitate sandboxed integration testing, where the original source directory of the main workspace is not accessible without more jumping through hoops.
requires exposing `:srcs` for all the toolchain modules, so they can be added as `runfiles` to the sandbox.
8dad4fd
to
22dbd3c
Compare
7665ea2
to
a19f1e1
Compare
a19f1e1
to
b680096
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thank you!
A few comments, though this already looks very good.
To be sure that the backwards compatibility aspect works we should also test this on some users of rules_nixpkgs. rules_haskell and daml come to mind.
keep aliases for backwards compatibility
it belongs there and is used only there
35eab0e
to
d90d092
Compare
the boilerplate for accessing runfiles turned out to be not needed. from now on one can just add targets or filenames for generating documentation and checking that the generated files are up to date under version control.
while incomplete, this should cover most existing use cases seamlessly, such that existing users would not notice the refactoring.
d90d092
to
29bae9a
Compare
this requires some more cleanup and refactoring before it is readable again, see TODOs.
bzlmod
module for core rulesbzlmod
modules for core rules and toolchains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Good working teasing those apart!
A few last minor comments, and avdv/daml@04dff55#r68737946. Feel free to merge once they're resolved.
This is one of those PRs, where git's colorMoved = default
and colorMovedWS = allow-indentation-change
is really useful.
# sorry for this mess. Bazel `str.format()` does not allow nested `{}` | ||
# pairs and `awk` is sensitive to line breaks. | ||
# TODO: consider alternative: leave reference for the end and just | ||
# append the generated string with `cat`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one can escape {
as {{
and then it can be nested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Does that make anything substantially better? I'll try...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not work, not even in Python 3.8 (ValueError: unexpected '{' in field name
). This is a pathological case. Just look at the amount of additional braces! It is probably better to have a simpler setup in the first place, as noted in the comment.
Uhm, that was a bit faster than intended, sorry about that! It looks like we lost the |
FTR, here are the changes that were necessary in the daml project to use rules_nixpkgs after extracting the modules: digital-asset/daml@main...avdv:rules_nixpkgs-pr-193 (due to not using |
@avdv Which patch do you mean? |
In daml they are applying a patch to rules_nixpkgs to avoid "occasional segmentation faults of nix": this one: I did not care too much about it, as I did not see a segfault and the patch could be adapted if needed. |
@avdv Thanks for testing and sharing the diff!
Raised a question here:
|
closes #182
This is a fairly large change in terms of LOC, and also has some noise due to a generated
README.md
being checked into version control. It's best to follow it commit by commit, as they are fairly self-contained.The main line of thought is to literally separate rules by concern, as described in #182, and keep the tests working (which accounts for most of the non-obvious changes).