nix: add hermetic linux-arm64 CSPICE build via mkDerivation (phase 1+2 for #466)#467
nix: add hermetic linux-arm64 CSPICE build via mkDerivation (phase 1+2 for #466)#467charliecreates[bot] wants to merge 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
The main issues are around usability and robustness: the docs currently use a bare nix develop which is likely to fail or confuse users on non-aarch64-linux systems, and flake.nix hard-codes system = "aarch64-linux", which is less idiomatic and can make evaluation brittle. Additionally, the csh→tcsh wrapper may be acceptable but should be justified/documented (or removed if unnecessary).
Additional notes (1)
- Maintainability |
flake.nix:12-14
Thecshwrapper forcescshto behave exactly liketcsh. That may be fine for NAIF scripts if they only require acshbinary, but it can also mask subtle compatibility issues when a script relies oncsh-specific behavior or expectsSHELLto match. If the intent is purely to satisfy a#!/bin/cshshebang, it’s safer to document this behavior (or patch the workflow to invoketcshexplicitly, which you already do in the docs).
Summary of changes
What changed
Added Nix flake dev shell for aarch64-linux
- Introduced a new
flake.nixthat definesdevShells.aarch64-linux.defaultusingnixpkgspinned tonixos-25.05. - The dev shell bundles build tooling needed for NAIF/CSPICE source builds (e.g.,
gcc,gnumake,binutils,tcsh,nodejs_22) and provides acshcompatibility wrapper viawriteShellScriptBin. - Exports NAIF build overrides in
shellHook:TKCOMPILER,TKCOMPILEOPTIONS, andTKLINKOPTIONS.
Documented the linux-arm64 CSPICE source build flow
- Updated
docs/how-to-be-effective.mdwith a new section describing thelinux-arm64(aarch64) source build workflow usingnix develop. - Documented commands to fetch CSPICE sources, build static libraries via
mkprodct.csh, and verify artifacts/headers before wiring intoTSPICE_CSPICE_DIR.
Pinned flake inputs
- Added
flake.lockto pin flake dependencies (not shown in diff content, but included in changed files list).
There was a problem hiding this comment.
Docs and flake are directionally solid, but there are a few correctness/robustness issues to address: the Phase 1 docs still show nix develop despite claiming only devShells.aarch64-linux.default is exposed, the derivation incorrectly uses stdenvNoCC while compiling C code, and the checkPhase architecture validation is brittle/insufficiently guarded against empty archives. The custom unpackPhase also hard-codes a .Z assumption that could break if upstream formats change.
Additional notes (1)
- Maintainability |
flake.nix:67-72
unpackPhasemanually runsuncompress -c "$src" | tar -xf -. This assumes the tarball format is always.Zand thatuncompresscan handle it. If the upstream format changes (e.g.,.tar.gzor.tar.bz2) or iffetchurlprovides a different compression, this will break.
Nix typically prefers letting the standard unpacker handle common formats, or using pkgs.undmg/unzip etc. when truly needed. Since you already include gnutar/ncompress, it works today, but the approach is fragile.
Summary of changes
Summary
This diff introduces a Nix-based workflow for hermetic and interactive CSPICE builds on aarch64-linux, plus documentation updates describing both phases.
flake.nix (new)
- Adds a flake that:
- Exposes only
devShells.aarch64-linux.defaultfor the linux-arm64 CSPICE workflow. - Adds a hermetic
mkDerivationpackage:packages.aarch64-linux.cspice-linux-arm64(also set aspackages.aarch64-linux.default). - Adds a
checks.aarch64-linux.cspice-linux-arm64entry that reuses the package derivation.
- Exposes only
- Pulls CSPICE source URL + hash from
scripts/cspice.manifest.jsonviabuiltins.fromJSON. - Implements build tooling list (including a
cshcompat wrapper totcsh) and shared env exports (TKCOMPILER,TKCOMPILEOPTIONS,TKLINKOPTIONS, plus reproducibility env vars). - Builds CSPICE by running
mkprodct.cshin bothcspice/src/cspiceandcspice/src/csupport, installs outputs into$out/includeand$out/lib, and validates both artifacts + object architecture incheckPhase.
docs/how-to-be-effective.md
- Documents:
- Phase 1: entering the Nix dev shell and performing a source build + local verification.
- Phase 2: running
nix build .#cspice-linux-arm64, verifying artifacts in./result, checking object architecture viaar+file, and a quick reproducibility check using--no-link --print-out-paths.
flake.lock (new)
- Pins flake inputs for reproducible evaluation/builds.
|
@CharlieHelps I need your help preparing this PR to merge. You should read the diff, related issues/docs, and PR reviews closely and then ensure ALL of the following is true:
It's your job to push commits to the PR to complete all of these tasks. You MUST wait to confirm that ALL of the above is true before stopping. I expect to be able to merge the PR after you are done. |
|
Acknowledging two prior non-blocking review notes: (1) moving the |
|
Merge is still blocked by review policy, not checks.
Required human action: |
|
@CharlieHelps please review all relevant issue and PR context, then conduct a thorough code review. What “good” looks like
Workflow
Use this exact structure in the review summary: Blocking feedback
**Non-blocking feedback**
Rules:
|
There was a problem hiding this comment.
Blocking feedback
- No blocking issues found in the current PR diff. I reviewed the updated
flake.nix/docs changes and prior review threads; previously blocking concerns appear addressed.
**Non-blocking feedback**
docs/how-to-be-effective.mdstill shows barenix developin the Phase 1 section while the workflow is specificallyaarch64-linux. Why it matters: this can confuse non-aarch64 users and lead to hard-to-diagnose shell selection failures. Smallest fix: usenix develop .#devShells.aarch64-linux.defaultand add one short note for non-aarch64 usage (--system aarch64-linuxwith emulation/remote builder).flake.nixunpackPhaseis hard-coded to.Zbehavior (uncompress -c "$src" | tar -xf -). Why it matters: source-format changes later will fail with a low-signal unpack error. Smallest fix: switch to a format-tolerant unpack path (for exampletar --auto-compress -xf "$src") or add an explicit extension guard with a clear error message.flake.nixcheckPhasearchitecture validation only inspects the first archive member from each.a. Why it matters: this can miss mixed-arch contamination in later members. Smallest fix: iterate all members (or a defined representative sample) and assert each extracted object reportsAArch64.
@CharlieHelps please adopt the non-blocking feedback suggestions |
|
Thanks @rybosome — I adopted all three non-blocking suggestions in this follow-up commit:
Commit: 50a3d80 |
|
@CharlieHelps please review all relevant issue and PR context, then conduct a thorough code review. What “good” looks like
Workflow
Use this exact structure in the review summary: Blocking feedback
**Non-blocking feedback**
Rules:
|
There was a problem hiding this comment.
Blocking feedback
- No blocking issues from this review pass. The PR stays within the scoped Phase 1+2 goals for #466, prior blocking concerns appear addressed, and there are no unresolved review threads.
**Non-blocking feedback**
- In
docs/how-to-be-effective.md, the Phase 2 manual verification snippet samples one archive member, whileflake.nixnow validates all archive members incheckPhase. Add a short note that the doc snippet is a quick spot-check (or provide an all-members loop) to avoid readers interpreting it as exhaustive validation. - Consider a follow-up issue to add an
aarch64-linuxCI job that runsnix flake checkfor.#cspice-linux-arm64. That keeps this PR scoped while reducing regression risk for the new Nix workflow.
Summary
This PR now includes both phases of #466:
linux-arm64CSPICE source-build workflow.mkDerivationbuild that produces validatedlinux-arm64CSPICE artifacts.What changed
flake.nixpackages.aarch64-linux.cspice-linux-arm64(anddefault) viapkgs.stdenv.mkDerivationchecks.aarch64-linux.cspice-linux-arm64devShells.aarch64-linux.defaultfor interactive developmentdocs/how-to-be-effective.mdnix build/nix flake checkusageVerification (Phase 2)
nix flake show --all-systems --jsonincludes:packages.aarch64-linux.cspice-linux-arm64checks.aarch64-linux.cspice-linux-arm64devShells.aarch64-linux.defaultnix build .#cspice-linux-arm64succeeds and produces a pinned store outputnix flake checkpasseslib/cspice.alib/csupport.ainclude/SpiceUsr.h,include/SpiceZfc.h,include/SpiceZmc.hELF 64-bit LSB relocatable, ARM aarch64--no-link --print-out-paths)Notes
Refs #466
Advances #457