59 lines
2.6 KiB
Nix
59 lines
2.6 KiB
Nix
# Shared crane wiring for the rust workspace: the cargo source
|
|
# filter, the once-built dependency artifacts, and the native build
|
|
# inputs every rust derivation (packages + checks) consumes.
|
|
# Imported per system from flake.nix.
|
|
{ pkgs, craneLib }:
|
|
let
|
|
inherit (pkgs) lib;
|
|
in
|
|
rec {
|
|
# Shared between buildDepsOnly + buildPackage + cargoClippy/cargoTest
|
|
# so every derivation in the chain sees the same toolchain shape.
|
|
# git: hive-c0re's `lifecycle::tests::setup_proposed_*` shell out to
|
|
# `git init` + commit under `cargo test` in the sandbox.
|
|
# sqlite: matrix-sdk's `sqlite` feature (`hive-matrix-mcp` workspace
|
|
# member) — the matrix-sdk-sqlite + rusqlite stack links against
|
|
# system libsqlite3 by default.
|
|
# cmake: builds `aws-lc-sys` (BoringSSL) from source — pulled in by
|
|
# the `rustls` (aws-lc-rs) crypto provider under the OTLP/reqwest
|
|
# stack in `hive-metric`.
|
|
nativeBuildInputs = [
|
|
pkgs.git
|
|
pkgs.sqlite
|
|
pkgs.pkg-config
|
|
pkgs.cmake
|
|
];
|
|
|
|
# Narrowed source tree the rust derivations consume: everything
|
|
# cargo cares about (Cargo.toml/Cargo.lock + *.rs/*.toml), selected
|
|
# via `lib.fileset` rather than crane's `cleanCargoSource` filter —
|
|
# filesets drop directories that contain no selected files, so
|
|
# adding or renaming a non-rust directory (nix modules, docs, …)
|
|
# does NOT bust this src hash (an empty dir under a plain source
|
|
# filter would). All non-rust runtime assets — branding + the claude
|
|
# prompt template + claude-settings.json — live in the separate
|
|
# `hyperhive-assets` derivation and are loaded by the binaries at
|
|
# runtime from `$HIVE_ASSETS_DIR`. Net effect: only `*.rs` /
|
|
# `*.toml` / `Cargo.lock` edits rebuild the rust derivations.
|
|
cleanSrc = lib.fileset.toSource {
|
|
root = ../.;
|
|
fileset = craneLib.fileset.commonCargoSources ../.;
|
|
};
|
|
|
|
# Build the workspace's dependency tree once, cached as its own
|
|
# derivation. Package builds and checks reuse this via
|
|
# `inherit cargoArtifacts;` so a workspace-only edit doesn't rebuild
|
|
# deps. All consumers use the same `cleanSrc` so the input hash
|
|
# stays consistent across the chain.
|
|
cargoArtifacts = craneLib.buildDepsOnly {
|
|
src = cleanSrc;
|
|
# Workspace Cargo.toml is virtual (no `[package].name`), so crane
|
|
# can't auto-derive a name. Spell it out explicitly — keeps the
|
|
# derivation name stable across crane bumps + silences the
|
|
# placeholder warning. Same `pname` for the dep + check
|
|
# derivations so they share a clean naming family.
|
|
pname = "hyperhive-workspace";
|
|
version = "0.1.0";
|
|
inherit nativeBuildInputs;
|
|
};
|
|
}
|