Skip to content

build(nix): resolve BATS helper libraries from the flake - #696

Merged
c-vigo merged 3 commits into
feature/625-nix-claude-migrationfrom
bugfix/695-nix-bats-libs
Jun 24, 2026
Merged

c-vigo merged 3 commits into
feature/625-nix-claude-migrationfrom
bugfix/695-nix-bats-libs

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

On the Nix toolchain the local BATS suite failed completely — 246 tests, 246
failures — every .bats file erroring in setup() with
Could not find library 'bats-support'. tests/bats/test_helper.bash resolved
the helper libraries (bats-support/-assert/-file) from node_modules
(npm) or the now-removed Debian /usr/lib path; on the Nix dev-shell neither
exists, BATS_LIB_PATH was unset, and just test-bats ran npx bats, which
fetches only bats-core (not the helpers).

This PR makes BATS come from the flake (the toolchain SSoT): bats wrapped with
its helper libraries is added to devTools, and BATS_LIB_PATH is exported in
the dev-shell and image so bats_load_library resolves the helpers from the Nix
store. Consumers are switched to the flake bats and the unused bats* npm
dependencies are removed.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • flake.nix — add batsWithLibs (bats wrapped with bats-support,
    bats-assert, bats-file) to the devTools SSoT; export BATS_LIB_PATH in
    the dev-shell (mkProjectShell) and the image env.
  • tests/bats/test_helper.bash — resolve the helpers via
    bats_load_library (BATS_LIB_PATH from the flake); drop the node_modules
    and /usr/lib branches.
  • justfile — test-bats invokes the flake bats instead of npx bats.
  • package.json / package-lock.json — remove the now-unused bats,
    bats-support, bats-assert, bats-file dependencies (keeps
    @devcontainers/cli).
  • .github/actions/setup-env/action.yml — skip the ad-hoc bats-action
    and BATS_LIB_PATH export under provision-via-flake (the flake provides
    bats); the action remains for non-flake callers. Updated the related comments.
  • tests/test_flake_devshell.py — add parity tests asserting the flake
    provides bats and that BATS_LIB_PATH exposes the three helper libraries.
  • CHANGELOG.md (+ synced .devcontainer copy) — Fixed entry.

Changelog Entry

Fixed

  • BATS suite no longer fails locally on the Nix toolchain (helper libraries unresolved) (#695)
    • tests/bats/test_helper.bash resolved the BATS helper libraries (bats-support/-assert/-file) from node_modules (npm) or the now-removed Debian /usr/lib path; on the Nix toolchain neither exists locally, so every .bats file errored in setup() (Could not find library 'bats-support') and all 246 tests failed
    • Added bats wrapped with its helper libraries to the flake devTools SSoT and exported BATS_LIB_PATH in the dev-shell and image, so bats_load_library resolves the helpers from the Nix store; simplified test_helper.bash to that single path, switched just test-bats to the flake-provided bats, and removed the now-unused bats* npm dependencies. CI provisions BATS from the flake under provision-via-flake (the ad-hoc bats-action steps now run only for non-flake callers)

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • nix develop --command just test-bats with node_modules removed: 246/246
    pass
    via the flake bats (previously 246/246 failed).
  • uv run pytest tests/test_flake_devshell.py: 6 passed (includes the new
    bats parity tests and bats --version running inside nix develop).
  • shellcheck -x tests/bats/test_helper.bash: clean.
  • nixfmt flake.nix: clean; nix eval of devShells, packages.devcontainerImage,
    and checks all evaluate.
  • jq empty package.json package-lock.json and yamllint on the action: clean.

Note: pre-commit's ruff/typos hooks cannot execute on the NixOS host
(manylinux binaries, no nix-ld), so those file hooks were not run locally;
ruff check/ruff format --check were verified via the Nix-native ruff.
CI re-runs the full pre-commit suite.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Sub-issue of the Nix migration epic #625; PR targets the epic branch
feature/625-nix-claude-migration. The remaining npx bats references in
docs/issues/ and docs/pull-requests/ are archived issue/PR records and were
intentionally left unchanged.

Refs: #695

c-vigo added 3 commits June 24, 2026 18:02
Add bats wrapped with its helper libraries (bats-support, bats-assert,
bats-file) to the devTools SSoT and export BATS_LIB_PATH in the dev-shell
and the image so bats_load_library resolves the helpers from the Nix
store. The npm (node_modules) and Debian (/usr/lib) resolution paths do
not exist on the Nix toolchain, which broke the local BATS suite.

Refs: #695
Switch every BATS consumer to the flake-provided bats:
- test_helper.bash resolves the helper libraries via bats_load_library
  (BATS_LIB_PATH from the flake), dropping the node_modules and /usr/lib
  branches.
- just test-bats invokes the flake bats instead of npx bats.
- remove the now-unused bats* npm dependencies from package.json/lock.
- setup-env skips the ad-hoc bats-action under flake provisioning (the
  flake provides bats); the action remains for non-flake callers.

Refs: #695
@c-vigo c-vigo self-assigned this Jun 24, 2026
@c-vigo
c-vigo merged commit addb632 into feature/625-nix-claude-migration Jun 24, 2026
2 checks passed
@c-vigo
c-vigo deleted the bugfix/695-nix-bats-libs branch June 24, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant