I’ve said it before: Nix is advanced alien technology that was badly damaged when it crash landed on Earth.

We’ve got a very nice setup that deeply integrates Nix/NixOS/Bazel (working name “straylight” for the Gibson fans) that builds most major languages well and rounds off the (very) rough corners. I’m dying to open source it but it takes time to detangle that kind of thing from your proprietary stuff. I paid in blood to know Nix inside out and I don’t want any more people to do that than already have. We use Tweag’s shit for some of the Haskell stuff.

Until then: if you’re ready to pay the price of learning this shit: you’ll get a favorable exchange rate by reading the source of nixpkgs. The docs/blogs are just usually wrong. There are exceptions (Xe is a baller), but mostly you’re flipping a coin whether or not an online resource will move you forwards or backwards.

Edit: Flakes aren’t an experimental new feature. They are a desperately needed fix to a badly broken status quo. Do not pass go, go directly to flakes.

How are you integrating bazel and nix?

My assumption is that bazel is running in an environment created by nix, so I wonder what you mean by 'deeply integrated'.

The devil as always is in the details, but in the broad strokes we have a pretty uniform/composable way to float stuff from the Nix store into Starlark and thereby put all of nixpkgs within Bazel’s reach. Doing like custom Bazel cc_toolchain stuff against Nix wrappers is, uh, an adventure. But you grind away at it and now you’ve got the C toolchain you want. Wash/rinse/repeat for all the other languages you use and before you know it you’ve got Nix’s determinism and Bazel’s crazy fast build times.

When I was at FB there were dozens if not hundreds of serious hackers working on this sort of thing, and they were fucking good at their jobs, but technology usually moves forward with time and this setup smokes where FB was at in 2018. I don’t know what they’re up to now, I bet it’s good.

I have spent a little bit of time working on a prototype of a setup like this, and have needed to write a lot of (hacky) glue and BUILD files.

I take it you have departed quite a bit from https://github.com/tweag/rules_nixpkgs ? Are you generating BUILD.bazel files for nixpkgs, or are you doing that by hand?