fix: select rust sources via filesets so new dirs keep the cargo cache
This commit is contained in:
parent
3069c11c3d
commit
c0bd77b314
1 changed files with 18 additions and 15 deletions
33
nix/rust.nix
33
nix/rust.nix
|
|
@ -3,6 +3,9 @@
|
||||||
# inputs every rust derivation (packages + checks) consumes.
|
# inputs every rust derivation (packages + checks) consumes.
|
||||||
# Imported per system from flake.nix.
|
# Imported per system from flake.nix.
|
||||||
{ pkgs, craneLib }:
|
{ pkgs, craneLib }:
|
||||||
|
let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
in
|
||||||
rec {
|
rec {
|
||||||
# Shared between buildDepsOnly + buildPackage + cargoClippy/cargoTest
|
# Shared between buildDepsOnly + buildPackage + cargoClippy/cargoTest
|
||||||
# so every derivation in the chain sees the same toolchain shape.
|
# so every derivation in the chain sees the same toolchain shape.
|
||||||
|
|
@ -21,21 +24,21 @@ rec {
|
||||||
pkgs.cmake
|
pkgs.cmake
|
||||||
];
|
];
|
||||||
|
|
||||||
# Narrowed source tree the rust derivations consume.
|
# Narrowed source tree the rust derivations consume: everything
|
||||||
# `cleanCargoSource` is crane's standard "everything cargo cares
|
# cargo cares about (Cargo.toml/Cargo.lock + *.rs/*.toml), selected
|
||||||
# about" filter (Cargo.toml/Cargo.lock + *.rs). All non-rust runtime
|
# via `lib.fileset` rather than crane's `cleanCargoSource` filter —
|
||||||
# assets — branding + the claude system prompt template +
|
# filesets drop directories that contain no selected files, so
|
||||||
# claude-settings.json — live in the separate `hyperhive-assets`
|
# adding or renaming a non-rust directory (nix modules, docs, …)
|
||||||
# derivation and are loaded by the binaries at runtime from
|
# does NOT bust this src hash (an empty dir under a plain source
|
||||||
# `$HIVE_ASSETS_DIR`. The unit tests in `hive-ag3nt::prompt` read
|
# filter would). All non-rust runtime assets — branding + the claude
|
||||||
# `prompts/system.md` directly from the workspace tree at *test*
|
# prompt template + claude-settings.json — live in the separate
|
||||||
# runtime (via `env!("CARGO_MANIFEST_DIR")` — a compile-time string,
|
# `hyperhive-assets` derivation and are loaded by the binaries at
|
||||||
# no file open at compile), so the prompt template doesn't have to
|
# runtime from `$HIVE_ASSETS_DIR`. Net effect: only `*.rs` /
|
||||||
# be in this fileset to keep `cargo test` honest. Net effect: tweaks
|
# `*.toml` / `Cargo.lock` edits rebuild the rust derivations.
|
||||||
# to any non-`*.rs` / non-`Cargo.*` file (README, branding, nix
|
cleanSrc = lib.fileset.toSource {
|
||||||
# modules, frontend tree, OR `hive-ag3nt/prompts/*`) do NOT bust
|
root = ../.;
|
||||||
# this src hash, so the rust derivations stay fully cached.
|
fileset = craneLib.fileset.commonCargoSources ../.;
|
||||||
cleanSrc = craneLib.cleanCargoSource ../.;
|
};
|
||||||
|
|
||||||
# Build the workspace's dependency tree once, cached as its own
|
# Build the workspace's dependency tree once, cached as its own
|
||||||
# derivation. Package builds and checks reuse this via
|
# derivation. Package builds and checks reuse this via
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue