Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: support 'nix build' for cometbft archive #16

Merged
merged 2 commits into from
Oct 25, 2024
Merged

Conversation

conorsch
Copy link
Contributor

The existing build.rs script assumes that go has been set up sufficiently, and calls out to it to build the static library for cometbft for linking against. That's rad, but naively calling out to go build from inside nix build fails, because the rust overlay doesn't know anything about golang, and forbids arbitrary network calls.

Instead, we'll have to be explicit about preparing the libcomebft.a static lib as a discrete output, and consuming it as an input in the rust build. We can do so by opting in to using a prebuilt lib via env var in the build.rs script.

This change improves the nix config, making it sufficiently defined to perform a nix build successfully. Careful attention was given to preserving the existing functionality so that cargo build will still do the right thing, as long as golang is available.

The existing build.rs script assumes that go has been set up
sufficiently, and calls out to it to build the static library for
cometbft for linking against. That's rad, but naively calling out to
`go build` from inside `nix build` fails, because the rust
overlay doesn't know anything about golang, and forbids arbitrary
network calls.

Instead, we'll have to be explicit about preparing the `libcomebft.a` static lib
as a discrete output, and consuming it as an input in the rust build.
We can do so by opting in to using a prebuilt lib via env var in the
`build.rs` script.

This change improves the nix config, making it sufficiently defined to
perform a `nix build` successfully. Careful attention was given to
preserving the existing functionality so that `cargo build` will still
do the right thing, as long as golang is available.
@conorsch conorsch changed the title feat: support 'nix build' for cometbft archive build: support 'nix build' for cometbft archive Oct 25, 2024
Copy link
Collaborator

@cronokirby cronokirby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cool!

In particular it's nice that it all still works the normal way if Nix isn't involved, which should match a lot of people's dev machines, where they can reasonably be assumed to have both Go and Rust installed.

@cronokirby cronokirby merged commit d91443c into main Oct 25, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants