Repository navigation
chore: add formatting & linting for Nix and shell + CI - #44
Merged
Merged
Conversation
Add treefmt-nix as the single formatter/linter runner (config in treefmt.nix), driving: * Nix: nixfmt + statix + deadnix * Shell: shfmt (2-space) + shellcheck Expose it via the flake's formatter (`nix fmt`) and checks.<system>.formatting (`nix flake check`) outputs, and add a CI workflow (.github/workflows/fmt.yml) that runs `nix fmt -- --ci` in the nixos/nix container (matching the existing test/release workflows). Reformat all tracked .nix files and install.sh to satisfy the tools, and fix a shellcheck SC2059 in install.sh by scoping the disable to the whole print_summary function. Document the workflow in agents.md. Closes #36
Add Makefile targets driving treefmt with -f to keep formatting and linting separate: * make fmt format in place (nixfmt + shfmt) * make fmt/check format check only (--ci, no writes) * make lint lint check only (statix + deadnix + shellcheck, --ci) Rework .github/workflows/fmt.yml into two independent jobs (format check + lint) that only CHECK — they never apply formatting, failing with a diff when something is off. Update agents.md accordingly.
The format/lint checks are light, so drop the nixos/nix `docker run` container wrapper (only needed for the heavy image builds' glibc-loader workaround) and instead install Nix on the runner with nix-installer-action (flakes enabled), running `make` directly (GNU Make is preinstalled on the GitHub Ubuntu runners).
# Conflicts: # Makefile # hosts/_appliance-disk/default.nix
`make lint/fix` runs statix + deadnix in write mode to auto-apply lint fixes in place (shellcheck has no autofixer; run `make lint` after to catch what's left).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #36.
Adds formatting + linting for the Nix and shell files, with CI to enforce it.
What's in here
treefmt.nix— single treefmt config driving every tool:nixfmt(RFC-style format) +statix(anti-pattern lints) +deadnix(dead-code removal)shfmt(format, 2-space indent to match existing scripts) +shellcheck(lint)flake.lock,*.terraform.lock.hcl,*.tar.gz, image artifacts)flake.nix— adds thetreefmt-nixinput plus:formatter.<system>→nix fmtapplies everything in-placechecks.<system>.formatting→nix flake checkverifies the tree is clean.github/workflows/fmt.yml— new CI job runningnix fmt -- --ciinside thenixos/nixcontainer, mirroring thedocker runpattern intest.yml/release.yml. Triggers on push tomain, PRs, and manual dispatch..nixfiles +install.sh) so CI is green. The only hand-written, non-mechanical change is ininstall.sh: theSC2059shellcheck disable now scopes the wholeprint_summaryfunction (the previous inline one only covered the first of ~9printf "$row"rows).agents.md— short contributor note onnix fmt/nix fmt -- --ci.Verification
nix fmt -- --ci→ 0 changed (the exact CI command)nix build .#checks.x86_64-linux.formatting→ passesnix flake check --no-build --all-systems→ all configs/outputs evaluatemake installer/drv+make appliance/drv→ both ISO derivations fully instantiate (confirms the deadnix/statix edits dropped nothing used)bash -n install.sh→ valid