Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 98 additions & 17 deletions pkgs/atlas-search/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@
# part of this package's runtime closure (verify:
# `nix-store -qR <out>`), and the installCheck proves the load
# works with no ATLAS_ORT_LIB set (fixtures/smoke_check.py).
#
# Dependency compilation is split from the package build when a
# craneLib is supplied (the package flake passes one): crane's
# buildDepsOnly compiles every registry dependency as its OWN
# derivation keyed only on Cargo.toml/Cargo.lock, so a change to
# workspace sources rebuilds just the workspace crates instead of
# the whole dependency tree (code#8392). Callers that do not pass
# craneLib (home/common) keep the monolithic buildRustPackage
# build below — same sources, same checks, no split.
{
lib,
rustPlatform,
callPackage,
python3,
craneLib ? null,
}:

let
Expand All @@ -32,24 +42,12 @@ let
# that release; the library baked in below must be the same one
# (code#6765, Drew's ruling 2026-11-08).
onnxruntime = callPackage ./onnxruntime { };
in

rustPlatform.buildRustPackage {
pname = "atlas-search";
version = "0.1.0";
src = ./.;

cargoLock.lockFile = ./Cargo.lock;

env.ATLAS_SEARCH_ORT_LIB_DEFAULT = "${onnxruntime}/lib/libonnxruntime.so";
ortLibEnv = {
ATLAS_SEARCH_ORT_LIB_DEFAULT = "${onnxruntime}/lib/libonnxruntime.so";
};

nativeInstallCheckInputs = [ python3 ];
doInstallCheck = true;
# The smoke: fixture FTS-only + embedded queries byte-compared
# with the recorded Python envelopes, plus the closure-ONNX
# load probe (an empty model dir must fail at the tokenizer,
# after runtime init — never at runtime resolution).
installCheckPhase = ''
installCheck = ''
runHook preInstallCheck
python3 ${./fixtures}/smoke_check.py $out/bin/atlas-search
runHook postInstallCheck
Expand All @@ -63,4 +61,87 @@ rustPlatform.buildRustPackage {
];
mainProgram = "atlas-search";
};
}
in
if craneLib != null then
let
# Two source tiers. The dependency layer sees only what can
# change dependency compilation: the manifests, the lockfile,
# the crate sources and schema/ (atlas-core include_str!s the
# stage DDL from schema/). The package layer additionally sees
# fixtures/: the test suite reads fixtures by relative path
# (atlas-core's eval tests open ../../fixtures/eval-smoke.json),
# so the check phase needs them in the tree — but a fixture edit
# must not rebuild the dependency layer, so they stay out of
# the deps tier. eval/, worker/ and the in-tree target/ are in
# neither (the installCheck references ./fixtures as its own
# store path, above).
depsSrc = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./crates
./schema
];
};

packageSrc = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./crates
./schema
./fixtures
];
};

commonArgs = {
strictDeps = true;
pname = "atlas-search";
version = "0.1.0";
env = ortLibEnv;
};

# The dependency layer: every registry crate compiled once,
# keyed on the deps tier above only. A workspace-source or
# fixture change leaves this derivation — and its store path —
# untouched.
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { src = depsSrc; });
in
craneLib.buildPackage (
commonArgs
// {
src = packageSrc;
inherit cargoArtifacts meta;

# Preserve the buildRustPackage behaviour this package had:
# the test suite runs in the check phase, and the smoke
# installCheck runs against the installed tree.
doCheck = true;

nativeInstallCheckInputs = [ python3 ];
doInstallCheck = true;
installCheckPhase = installCheck;
}
)
else
rustPlatform.buildRustPackage {
pname = "atlas-search";
version = "0.1.0";
src = ./.;

cargoLock.lockFile = ./Cargo.lock;

env = ortLibEnv;

nativeInstallCheckInputs = [ python3 ];
doInstallCheck = true;
# The smoke: fixture FTS-only + embedded queries byte-compared
# with the recorded Python envelopes, plus the closure-ONNX
# load probe (an empty model dir must fail at the tokenizer,
# after runtime init — never at runtime resolution).
installCheckPhase = installCheck;

inherit meta;
}
17 changes: 17 additions & 0 deletions pkgs/atlas-search/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion pkgs/atlas-search/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
# Crane: splits dependency compilation out of the package build
# so workspace-source changes reuse the dependency layer
# (code#8392). Pinned to the rev the code repo's root lock
# already carries.
crane = {
url = "github:ipetkov/crane/01bc1d404a51a0a07e9d8759cd50a7903e218c82";
};
};

outputs =
Expand All @@ -23,6 +30,7 @@
nixpkgs,
rust-overlay,
flake-utils,
crane,
...
}:
flake-utils.lib.eachDefaultSystem (
Expand All @@ -41,7 +49,8 @@
cargo = rustToolchain;
rustc = rustToolchain;
};
atlas-search = pkgs.callPackage ./default.nix { inherit rustPlatform; };
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
atlas-search = pkgs.callPackage ./default.nix { inherit rustPlatform craneLib; };
in
{
packages = {
Expand Down
Loading