Skip to content

new(cockroachdb): distributed SQL with Pebble storage engine#13122

Open
tannevaled wants to merge 4 commits into
pkgxdev:mainfrom
tannevaled:new/cockroachdb
Open

new(cockroachdb): distributed SQL with Pebble storage engine#13122
tannevaled wants to merge 4 commits into
pkgxdev:mainfrom
tannevaled:new/cockroachdb

Conversation

@tannevaled
Copy link
Copy Markdown
Contributor

Summary

Add a pantry recipe for cockroachdb/cockroach — a Go-based distributed
SQL database that uses Pebble (pure-Go RocksDB rewrite) as its storage
engine, sidestepping the C++ rocksdb / cgo build hell that complicates
alternatives such as TiKV.

  • Source build (no vendored binaries).
  • Builds the cockroach-short bazel target via bazelisk, which produces
    a fully functional cockroach binary without the embedded JS DB Console
    (the maintainer-recommended "lean" build, cf. docs/building.md).
  • Pins USE_BAZEL_VERSION to match the in-tree .bazelversion (7.6.0).
  • A stub stamp.sh is injected to satisfy bazel's
    workspace_status_command from a tarball checkout that has no .git/.

Build notes

  • The legacy make buildoss target referenced in older Arch AUR PKGBUILDs
    no longer exists in v23+ — the top-level GNUmakefile is a thin wrapper
    around ./dev (bazel).
  • nixpkgs gives up on source builds since v23 and just rewraps the
    upstream binary tarballs — we choose the source-build path instead
    (HARD RULE: no vendoring).
  • Cross-referenced: Arch AUR (legacy v19 make path), nixpkgs (binary-only
    since v23), upstream docs/building.md.

Test plan

  • pkgx +github.com/cockroachdb/cockroach -- cockroach version reports v26.2.1
  • cockroach start-single-node --insecure boots a SQL listener
  • CI green on linux/x86-64, linux/aarch64, darwin/x86-64, darwin/aarch64

🤖 Generated with Claude Code

Add recipe for cockroachdb/cockroach v26.x. CockroachDB is a Go-based
distributed SQL database that uses Pebble (a pure-Go RocksDB rewrite) as
its storage engine, avoiding the C++ rocksdb / cgo build complexity that
plagues TiKV.

Build path: since v23 cockroach moved fully to bazel; the legacy
`make buildoss` target no longer exists. The recipe builds the
`cockroach-short` bazel target via bazelisk, which excludes the
embedded JS web UI but produces a fully functional `cockroach` binary
(this is the maintainer-recommended "lean" build).

Notes:
  - github source tarballs lack a .git dir; stub stamp.sh injects the
    version into bazel's stable-status so the binary reports v{{version}}
  - cross-references: Arch AUR PKGBUILD (v19, legacy make), nixpkgs
    23.1 (gave up on source builds), and upstream docs/building.md.
cockroachdb does not publish GitHub releases; it only pushes git tags.
The default github: <org>/<repo> resolves to .../releases/tags which
returns an empty list, leading to "no versions parsed". Switch to
.../tags so version resolution finds v26.2.1 and friends.
bazel's default sandbox masks /toolchain/gcc on the host, which pkgx's
gcc wrapper script tries to exec at runtime, causing:
  gcc: line 25: /toolchain/gcc: No such file or directory

Use --spawn_strategy=local to bypass the sandbox; the bazel build then
runs against the same toolchain pantry already wired up. Same pattern
is conceptually equivalent to starpls's --action_env hack but works
when actual cgo compilation is needed (cockroach has jemalloc, geos
and proj as c-deps).
bazel's --incompatible_strict_action_env (enabled in cockroach's
.bazelrc) wipes HOME/PATH from spawned compile actions. pkgx's gcc
wrapper at $HOME/toolchain/bin/gcc execs $HOME/toolchain/<tool>, so
HOME=='' degrades to /toolchain/gcc and exits 127.

Drop the HOME override (was clobbering pantry's prepared toolchain
location), preserve the build shell's HOME/PATH and forward both to
bazel via --action_env. Also use a 'EOSTAMP' heredoc with sed
substitution so the stamp script does not expand $() at write time
in the wrong shell context.
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.

1 participant