Skip to content

chore: add treefmt formatting (nix fmt + pre-commit + CI check) - #4

Merged
Unisay merged 1 commit into
mainfrom
chore/treefmt
Jun 15, 2026
Merged

chore: add treefmt formatting (nix fmt + pre-commit + CI check)#4
Unisay merged 1 commit into
mainfrom
chore/treefmt

Conversation

@Unisay

Copy link
Copy Markdown
Collaborator

Roll the ecosystem formatting setup (ADR 0007, piloted in purescript-lua/purescript-lua-effect#6) onto this fork.

Tooling. Copies treefmt.nix/.tidyrc.json/.lua-format and wires treefmt-nix into the flake: nix fmt formats, checks.formatting is exposed, the dev shell installs a content-based pre-commit hook, and CI gains a format-check step. The check is content-based (nix fmt && git diff --exit-code) rather than treefmt --ci, since the in-place formatters bump mtime even when content is unchanged. LuaFormatter is kept over StyLua because it preserves the parentheses pslua's foreign-file parser requires.

Fork specifics. Replaces the fork's bespoke .lua-format with the ecosystem canon (compact one-liners); the nginx FFI keeps its luacheck --globals ngx flag, with --max-line-length raised to 130. dhall format also normalised packages.dhall. Verified locally: build + luacheck --globals ngx --max-line-length 130 green.

Wire treefmt via treefmt-nix: nixfmt, dhall format, purs-tidy (.tidyrc.json)
and LuaFormatter for the FFI (.lua-format, kept over StyLua because it
preserves the parentheses pslua's parser needs). `nix fmt` formats; the dev
shell installs a content-based pre-commit hook and CI runs
`nix fmt && git diff --exit-code` (content-based, since the in-place
formatters bump mtime and would trip treefmt --fail-on-change). Lua lines
budget 130 cols, matching the raised `luacheck --max-line-length`; the
nginx FFI keeps its `--globals ngx` luacheck flag. Replaces the bespoke
.lua-format with the ecosystem canon (compact one-liners).

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR rolls out standardized formatting infrastructure (treefmt-nix + nix fmt), including a pre-commit hook and a CI formatting check, aligning this fork with the upstream ecosystem formatting setup.

Changes:

  • Adds treefmt-nix integration to the flake (formatter output + checks.formatting) and documents formatting usage.
  • Introduces formatting configs for PureScript (.tidyrc.json) and Lua FFI (.lua-format) and normalizes Dhall formatting.
  • Updates CI to run a content-based formatting check (nix fmt && git diff --exit-code) alongside existing build/lint steps.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
treefmt.nixDefines the treefmt-nix formatting module (nixfmt, dhall, purs-tidy, lua-format, excludes).
flake.nixWires treefmt-nix into the flake outputs and adds a devShell hook to install a pre-commit formatter check.
.github/workflows/ci.ymlAdds a formatting check step and updates luacheck flags.
.tidyrc.jsonAdds purs-tidy configuration for formatting PureScript sources.
.lua-formatReplaces LuaFormatter config with the ecosystem canonical settings and updated line budget.
AGENTS.mdDocuments formatting workflow (nix fmt + diff-based check) and updates lint command.
packages.dhallNormalizes formatting output (removes trailing whitespace line).
flake.lockAdds the treefmt-nix input pin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadtreefmt.nix
Comment threadtreefmt.nix
Comment threadflake.nix
Comment threadflake.nix
@Unisay
Unisay merged commit ec4372c into mainJun 15, 2026
2 checks passed
@Unisay
Unisay deleted the chore/treefmt branch June 15, 2026 08:09
Sign up for freeto 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.

2 participants

@Unisay