urbit / vere

An implementation of the Urbit runtime
MIT License
55 stars 38 forks source link

nix build .#urbit #404

Open bohendo opened 1 year ago

bohendo commented 1 year ago

Given bazel usage, is it possible to wrap this new build system in the flake.nix file to provide a nix build .#urbit command?

This would be intended for one-off usage while integrating urbit into other projects, or for easy global installations with nix-env or nix profile, it doesn't need to be fast/incremental as the current bazel-based build system seems great for active development.

As a starting point, we could add the following to the flake.nix outputs:

      packages = {
        urbit = pkgs.stdenv.mkDerivation {
          pname = "urbit";
          version = "2.5";
          src = ./.;
          buildInputs = with pkgs; [
            toolchain
          ]
          ++ (with pkgs; [
            autoconf
            automake
            bazel_5
            binutils # for `nm`
            jdk11_headless
            libtool
            m4
          ]);
          buildPhase = ''
            bazel build :urbit
            cp bazel-bin/pkg/vere/urbit $out/bin
          '';

The buildInputs use the same build toolchain dependencies as the devShells, and running nix build .#urbit seems to kick-off in a way that suggests dependencies are available. But, as is, it fails with:

> FATAL: mkdir('/homeless-shelter/.cache/bazel/_bazel_nixbld'): (error: 13): Permission denied

I assume, if we could prevent bazel from caching incremental builds, then we could stop it from accessing the shared cache in $HOME. But I'm not familiar with bazel & maybe this kind of configuration isn't possible.

Is this rabbit hole worth exploring? Is there any chance that such a nix expression would ever work?

Thank you in advance for any feedback/guidance you all could provide.

ilyakooo0 commented 1 year ago

This is a lot harder than it seems.

ilyakooo0 commented 1 year ago

Also: nixpkgs has a recent version of vere. Might make more sense to just use that.

barter-simsum commented 1 year ago

I wouldn't put too much work into anything that adds a dependency on bazel or involves delving too much into the bazel build system. We have plans to eventually get away from it.

ilyakooo0 commented 1 year ago

@barter-simsum what are you planning to move to?

barter-simsum commented 1 year ago

@ilyakooo0 a secret third thing

mrdomino commented 8 months ago

@barter-simsum it'd be useful to me to know what build system you guys are moving to, as I'm trying to get a build working against a custom toolchain (cosmopolitan libc, specifically.)