build(nix): add per-crate crane workspace builds#1652
Conversation
2adab70 to
3db6ac8
Compare
|
/ok-to-test deea799 |
|
/ok-to-test ab56476 |
|
/ok-to-test 1036e11 |
|
/ok-to-test 37097f1 |
37097f1 to
58bafc4
Compare
|
/ok-to-test 58bafc4 |
58bafc4 to
1912489
Compare
|
/ok-to-test 1912489 |
|
/ok-to-test 8ac1241 |
|
/ok-to-test 886053a |
There was a problem hiding this comment.
Does this mean that we've removed the e2e tests?
| openshell-vfio-test | ||
| cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }} | ||
|
|
||
| lint: |
There was a problem hiding this comment.
Does this mean that the lint step is run after the test step?
| fi | ||
| exit 0 | ||
|
|
||
| python: |
There was a problem hiding this comment.
Should we still run a python linter?
| - name: Test | ||
| run: mise run test:python | ||
|
|
||
| markdown: |
There was a problem hiding this comment.
I didn't see a markdown linter in the nix targets.
| exit 1 | ||
| fi | ||
|
|
||
| license-headers: |
There was a problem hiding this comment.
Is this the same as the spdx-headers nix check?
| description = "OpenShell development environment"; | ||
|
|
||
| nixConfig = { | ||
| extra-substituters = [ "https://openshell.cachix.org" ]; |
There was a problem hiding this comment.
Can you expand on what this does?
There was a problem hiding this comment.
This is responsible for the caching. This is a temporary hosted cache for you to try out the caching feature. Only CI can push to it but everyone can pull.
| crates = { | ||
| openshell = workspaceCrates.openshell-cli.package; | ||
| openshell-gateway = workspaceCrates.openshell-server.package; | ||
| openshell-sandbox = workspaceCrates.openshell-sandbox.package; | ||
| openshell-driver-vm = workspaceCrates.openshell-driver-vm.package; | ||
| openshell-driver-kubernetes = workspaceCrates.openshell-driver-kubernetes.package; | ||
| openshell-driver-podman = workspaceCrates.openshell-driver-podman.package; | ||
| }; |
There was a problem hiding this comment.
This looks like a subset of our crates. What's special about these?
There was a problem hiding this comment.
These are the only crates that produce binaries afaik.
| openshell-bootstrap-test | ||
| openshell-cli-test | ||
| openshell-core-test | ||
| openshell-driver-docker-test | ||
| openshell-driver-kubernetes-test | ||
| openshell-driver-podman-test | ||
| openshell-driver-vm-test | ||
| openshell-ocsf-test | ||
| openshell-policy-test | ||
| openshell-prover-test | ||
| openshell-providers-test | ||
| openshell-router-test | ||
| openshell-sandbox-test | ||
| openshell-server-macros-test | ||
| openshell-server-test | ||
| openshell-tui-test | ||
| openshell-vfio-test |
There was a problem hiding this comment.
This is somewhat of an arbitrary location to start the 🧵, but one that that jumped out as I'm reviewing is how often we need to repeat crate names. Is that assessment right? Is this something we can improve on?
There was a problem hiding this comment.
It depends, we can definitely store this in a variable. I just wanted to be as explicit as possible but we can definitely make it shorter.
886053a to
2fbf7e3
Compare
Add crane-based package outputs for the main OpenShell crates and a default symlinkJoin package. The new workspace helper derives each crate's transitive workspace dependency closure, builds from minimal source trees, and declares the assets each crate needs at compile time. Build each crate in three layers: 1. crates.io dependencies with crane buildDepsOnly 2. first-party workspace dependency libraries 3. the final real crate The workspace-libs layer builds the selected package with the same `-p <crate>` selection as final so Cargo feature unification matches, but overlays a crane-generated dummy source for the leaf crate. After that layer builds, remove the dummy leaf artifacts with `cargo clean --release -p <crate>` so the final layer cannot reuse or package stub outputs. This lets leaf edits reuse cached first-party libs while still compiling and linking the real leaf crate. Add explicit `[lib]` target names and `path = "src/lib.rs"` entries to workspace crates. The Nix source minimizer keeps every member Cargo.toml but omits source trees outside the selected crate closure; explicit target paths let Cargo resolve those member manifests without relying on auto-discovery of files that are intentionally absent. They also give crane's dummy source generation a stable target shape. Guard the openshell-core build script's `.git` rerun paths so Cargo does not mark core dirty in Nix source trees where `.git` is absent. Without this, core recompiled in the final layer and cascaded into its dependents. Known limitation: the VM driver package is wired into the flake, but the Nix build does not yet provide the compressed VM runtime artifacts that openshell-driver-vm embeds. For now that crate builds via its stub-resource fallback rather than producing a fully usable VM driver package. Ignore Nix `result*` symlinks created by local builds.
Signed-off-by: Simon Scatton <sscatton@nvidia.com>
Signed-off-by: Evan Lezar <elezar@nvidia.com>
adf92e7 to
eab1d5e
Compare
Add crane-based package outputs for the main OpenShell crates and a default symlinkJoin package. The new workspace helper derives each crate's transitive workspace dependency closure, builds from minimal source trees, and declares the assets each crate needs at compile time.
Build each crate in three layers:
The workspace-libs layer builds the selected package with the same
-p <crate>selection as final so Cargo feature unification matches, but overlays a crane-generated dummy source for the leaf crate. After that layer builds, remove the dummy leaf artifacts withcargo clean --release -p <crate>so the final layer cannot reuse or package stub outputs. This lets leaf edits reuse cached first-party libs while still compiling and linking the real leaf crate.Add explicit
[lib]target names andpath = "src/lib.rs"entries to workspace crates. The Nix source minimizer keeps every member Cargo.toml but omits source trees outside the selected crate closure; explicit target paths let Cargo resolve those member manifests without relying on auto-discovery of files that are intentionally absent. They also give crane's dummy source generation a stable target shape.Guard the openshell-core build script's
.gitrerun paths so Cargo does not mark core dirty in Nix source trees where.gitis absent. Without this, core recompiled in the final layer and cascaded into its dependents.Known limitation: the VM driver package is wired into the flake, but the Nix build does not yet provide the compressed VM runtime artifacts that openshell-driver-vm embeds. For now that crate builds via its stub-resource fallback rather than producing a fully usable VM driver package.
Ignore Nix
result*symlinks created by local builds.Summary
Related Issue
Changes
Testing
mise run pre-commitpassesChecklist