Hermetic stand-alone nix+bazel combo

134 views
Skip to first unread message

Filip Filmar

unread,
Apr 9, 2024, 11:01:44 AMApr 9
to bazel-discuss
Hi folks. So I tinkered a bit.

Would someone be game to try out https://github.com/filmil/bazel-nix-flakes ?

This is a small repo, based upon https://github.com/tweag/rules_nixpkgs, which self-installs nix into bazel's cache and then builds and runs a hello world program.

That is, it allows you to use nixpkgs software in your bazel builds without having nix installed at all. Under the hood it uses existing tools for installing nix into an arbitrary file prefix. The idea is to make use of the vast nixpkgs repo in bazel builds, without needing to spend time bazelizing the world.

The original rules expect a nix installation, which means they are not directly usable if you don't already run nix. The above example does not require having nix installed, and anyone should be able to build it.

An issue I observed is that the bazel daemon decides to shut down in a few seconds, instead of staying around for the default ~3 hours (10800 seconds). Ideas for resolving that are welcome.

F

László Csomor

unread,
Apr 10, 2024, 10:31:03 AMApr 10
to Filip Filmar, bazel-discuss
Hey,

> An issue I observed is that the bazel daemon decides to shut down in a few seconds, instead of staying around for the default ~3 hours (10800 seconds). Ideas for resolving that are welcome.

`less $(bazel info server_log)` could reveal that.

It's possible that the daemon OOM'd, or maybe there are other bazel
deamons running on the system (happens if you build from multiple
workspaces and/or with multiple output roots) and the system is low on
memory. Does any of those sound plausible?

Cheers,
László

--
László Csomor | las...@engflow.com | Founding Engineer
EngFlow GmbH | Fischerweg 51, 82194 Gröbenzell, Germany
Geschäftsführer: Ulf Adams | Amtsgericht München, HRB 255664
https://www.engflow.com
> --
> You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAKaOXigBe1fieh%2BBTURHWwZde4V_Q5iLOSPsL6ztX%2BZJOSbNVg%40mail.gmail.com.

Filip Filmar

unread,
Apr 10, 2024, 1:18:50 PMApr 10
to László Csomor, bazel-discuss
On Wed, Apr 10, 2024 at 7:30 AM László Csomor <las...@engflow.com> wrote:
It's possible that the daemon OOM'd, or maybe there are other bazel
deamons running on the system (happens if you build from multiple
workspaces and/or with multiple output roots) and the system is low on
memory. Does any of those sound plausible?

The server logs didn't contain anything special - but the problem just went away today, without me doing anything.

This makes me think that low memory might be the culprit, but I don't really have proof at the moment. But
I could check the next time it re-appears.

F
 

Filip Filmar

unread,
May 11, 2024, 11:01:17 AMMay 11
to László Csomor, bazel-discuss
In the case someone cares, I may have emerged victorious.

Details of the ordeal, and links to results and such here: https://hdlfactory.com/post/2024/04/20/nix-bazel-%EF%B8%8F/
Reply all
Reply to author
Forward
0 new messages