thoughtpolice / buck2-nix

Do not taunt happy fun ball
59 stars 4 forks source link

Alternative sysroots #20

Open GregBowyer opened 1 year ago

GregBowyer commented 1 year ago

Not quite sure how to ask this so well asking

How could this be used to create and use an alternate (not nixos) sysroot.

My usecase is drag the toolchain from the void ^H^H^H^H nixos but provide a sysroot from something old, gross and crufty.

My needs are:

thoughtpolice commented 1 year ago

Sorry for missing this.

It's something I've thought about but it's definitely unsupported. I think you're probably best off using the upstream buck2-prelude and using something like Zig to compile binaries. You don't need the custom code or APIs to do that. There is upstream code to do it already.

This example calls the zig_cxx_toolchain function to download a Zig binary and configures buck2 to use zig cc as the C/C++ compiler. This can probably handle both the cases you want to some extent (M1 cross compilation is limited to non-Foundation libc, while I don't even know what glibc version RHEL 7 needs) but you'll likely need to fiddle with it yourself a bit.

https://github.com/facebook/buck2/tree/main/examples/toolchains/cxx_zig_toolchain https://github.com/facebook/buck2/blob/main/examples/toolchains/cxx_zig_toolchain/toolchains/BUCK