tweag / nix_bazel_codelab

Nix+Bazel Codelab
Apache License 2.0
50 stars 4 forks source link

Provide dedicated tutorial for the rules_nixpkgs setup #41

Open GuillaumeGen opened 1 year ago

GuillaumeGen commented 1 year ago

This is a Bazel tutorial, where Bazel is installed with Nix, but one could do exactly the same tutorial and install Bazel natively, it would work exactly the same. The advantages of using Nix is hidden in the WORKSPACE file, where all the programming languages dependencies that we are dealing with are installed using Nix. But this is completely hidden to the reader of this tutorial. (And it is not a bug that it is hidden, I mean, there could be another tutorial focusing on it, but it should definitely not be mixed with this one).

aherrmann commented 1 year ago

Indeed, this tutorial focuses on the Bazel aspect and only uses Nix to setup the project in a hermetic way. It can still function as an example project, after all the setup of all the toolchains with Nix in WORKSPACE could be reused by another project.

rules_nixpkgs should have a user-guide. Once that exists this codelab should link to it.

Do you think that outside of that this codelab should include exercises touching on rules_nixpkgs as well? E.g. letting the reader import a toolchain in the WORKSPACE file?

GuillaumeGen commented 1 year ago

My feeling is that it is a good tutorial, but not the one I expected when seeing the title.

aherrmann commented 1 year ago

Right, the first sentence in the README tries to clarify that

This set of exercises is a practical introduction to building polyglot projects with Bazel, supported by Nix for reproducible, hermetic build environments.

I.e. it's a bazel codelab for a nix+bazel project setup.

As you say we probably don't want to overload the reader by having them set up all the nixpkgs toolchain imports here as well. Messing with the WORKSPACE is usually more advanced than configuring BUILD files, so, it makes sense to first guide the reader through the BUILD files. Perhaps we could add a last exercise that adds some nixpkgs_packages tool or library dependency and uses that in some way to at least introduce simple interaction with rules_nixpkgs directly here. WDYT?