Variation of #214 (Rule to generate docker images with nix store paths)
Reduced change set of #214, with motivation of getting some momentum behind this.
Notable changes, utilizing the bazel-support directory to store default.nix and BUILD files so the docker definition can hook in.
TODO:
- [ ] Tests
- [ ] Documentation
- [ ] Allow for build artifacts to be bundled
Ideally, I'm going to use this as starting point so I can get singularity image builds more seamlessly in my workflow as an approach to #291
@jcpetruzza @aherrmann
Looks like the CI errors are due to the tilde in path issue that @aherrmann encountered a little while ago.
Oh interesting. Is this the work around? https://github.com/NixOS/nix/issues/7742#issuecomment-1420407931
I'll take a stab at this later today
Oh interesting. Is this the work around? NixOS/nix#7742 (comment)
I'll take a stab at this later today
Yeah, I think that should do the trick. From the documentation for nixpkgs_package:
Note, labels to external workspaces will resolve to paths that contain
~characters if the Bazel flag--enable_bzlmodis true. Nix does not support~characters in path literals at the time of writing, see #7742. Meaning, the result of location expansion may not form a valid Nix path literal. Use./$${"$(location @for//:example)"}to work around this limitation if you need to pass a path argument via--arg, or pass the resulting path as a string value using--argstrand combine it with an additional--arg workspace_root ./.argument usingworkspace_root + ("/" + path_str).
Sorry for the failure spam. I was unable to replicate this locally + found additional failure cases I wasn't seeing locally.
If this doesn't work, I will revisit later
Yeah. No idea. Running bazel test tests:all from testing/core passes locally, and I have no weird _main~non_module_deps~hello external dep (tried bazel_5 and bazel_6). Also seems to work executing .github/build-and-test. I guess I don't really understand how these special paths are arising?
I guess I don't really understand how these special paths are arising?
They should arise when you enable bzlmod either by bazel test --config=bzlmod in testing/core, or with export BZLMOD_ENABLED=true when running .github/build-and-test.
I'd like to try and get this merged. Unfortunately this commit that refactored _nixpkgs_package_impl has caused a non-trivial merge conflict. I'll have a go at resolving it when I have some time though.
I've been using an extension of this that packages build artifacts: https://github.com/cemel-jhu/rules_nixpkgs/pull/1/files