chore(nix): add style tooling #52

Merged
alexion merged 1 commits from setup-nix-style-tools into main 2026-09-16 00:14:11 -04:00
Owner

Summary

  • add treefmt-nix wiring for the repository Nix formatter
  • add statix configuration for project lint policy
  • add a nix-style-check app that runs formatter, statix, and deadnix checks without applying fixes

Verification

  • nix eval --raw .#apps.x86_64-linux.nix-style-check.type
  • nix eval --raw .#formatter.x86_64-linux.type
## Summary - add treefmt-nix wiring for the repository Nix formatter - add statix configuration for project lint policy - add a nix-style-check app that runs formatter, statix, and deadnix checks without applying fixes ## Verification - nix eval --raw .#apps.x86_64-linux.nix-style-check.type - nix eval --raw .#formatter.x86_64-linux.type
Author
Owner

Follow-up pushed: a779beb refactor(nix): simplify style tool outputs.\n\nThis removes the speculative multi-system helpers and keeps the new formatter/app surfaces explicitly scoped to x86_64-linux. Re-verified with:\n\n- nix eval --raw .#apps.x86_64-linux.nix-style-check.type\n- nix eval --raw .#formatter.x86_64-linux.type

Follow-up pushed: `a779beb refactor(nix): simplify style tool outputs`.\n\nThis removes the speculative multi-system helpers and keeps the new formatter/app surfaces explicitly scoped to `x86_64-linux`. Re-verified with:\n\n- `nix eval --raw .#apps.x86_64-linux.nix-style-check.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`
Author
Owner

Follow-up pushed: 9ebd79f refactor(nix): move style app wiring into dotfiles.\n\nChanges:\n- moved formatter/app wiring from flake.nix into src/dotfiles/apps.nix\n- removed standalone treefmt.nix and kept the small treefmt config with the app surface\n- renamed the app to style-check so it can grow beyond Nix-only checks later\n- added the remote deployment flake-app idea to docs/TODO.md\n\nRe-verified with:\n\n- nix eval --raw .#apps.x86_64-linux.style-check.type\n- nix eval --raw .#formatter.x86_64-linux.type\n- nix eval --raw .#apps.x86_64-linux.nix-style-check.type fails, confirming the old app name is gone

Follow-up pushed: `9ebd79f refactor(nix): move style app wiring into dotfiles`.\n\nChanges:\n- moved formatter/app wiring from `flake.nix` into `src/dotfiles/apps.nix`\n- removed standalone `treefmt.nix` and kept the small treefmt config with the app surface\n- renamed the app to `style-check` so it can grow beyond Nix-only checks later\n- added the remote deployment flake-app idea to `docs/TODO.md`\n\nRe-verified with:\n\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`\n- `nix eval --raw .#apps.x86_64-linux.nix-style-check.type` fails, confirming the old app name is gone
Author
Owner

Follow-up pushed: 3d3c3f7 refactor(nix): split formatter and app outputs.\n\nFinal shape:\n- flake.nix passes system = "x86_64-linux" into src/dotfiles.\n- src/dotfiles/formatter.nix owns treefmt evaluation and returns the formatter derivation.\n- src/dotfiles/apps.nix only defines flake apps and receives the formatter during import.\n- src/dotfiles/default.nix sets formatter.${system} and apps.${system} directly in the returned flake attrset.\n\nVerified:\n- nix eval --raw .#apps.x86_64-linux.style-check.type\n- nix eval --raw .#formatter.x86_64-linux.type

Follow-up pushed: `3d3c3f7 refactor(nix): split formatter and app outputs`.\n\nFinal shape:\n- `flake.nix` passes `system = "x86_64-linux"` into `src/dotfiles`.\n- `src/dotfiles/formatter.nix` owns treefmt evaluation and returns the formatter derivation.\n- `src/dotfiles/apps.nix` only defines flake apps and receives the formatter during import.\n- `src/dotfiles/default.nix` sets `formatter.${system}` and `apps.${system}` directly in the returned flake attrset.\n\nVerified:\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`
Author
Owner

Follow-up pushed: 5256e52 refactor(nix): inline flake system argument.\n\nRemoved the one-use let system = "x86_64-linux" block in flake.nix and passes the system string directly to src/dotfiles.\n\nVerified:\n- nix eval --raw .#apps.x86_64-linux.style-check.type\n- nix eval --raw .#formatter.x86_64-linux.type

Follow-up pushed: `5256e52 refactor(nix): inline flake system argument`.\n\nRemoved the one-use `let system = "x86_64-linux"` block in `flake.nix` and passes the system string directly to `src/dotfiles`.\n\nVerified:\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`
Author
Owner

Follow-up pushed: 0114bed refactor(nix): inline formatter evaluation.\n\nRemoved the one-use pkgs and treefmtEval let bindings from src/dotfiles/formatter.nix. The formatter module now returns the evaluated wrapper directly.\n\nVerified:\n- nix eval --raw .#formatter.x86_64-linux.type\n- nix eval --raw .#apps.x86_64-linux.style-check.type

Follow-up pushed: `0114bed refactor(nix): inline formatter evaluation`.\n\nRemoved the one-use `pkgs` and `treefmtEval` let bindings from `src/dotfiles/formatter.nix`. The formatter module now returns the evaluated wrapper directly.\n\nVerified:\n- `nix eval --raw .#formatter.x86_64-linux.type`\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`
Author
Owner

Follow-up pushed: 1cfab7e refactor(nix): expose formatter wrapper in outputs.\n\nChanged src/dotfiles/formatter.nix to return the treefmt evaluation object. src/dotfiles/default.nix now uses formatter.config.build.wrapper directly for both the flake formatter output and the style-check app input.\n\nVerified:\n- nix eval --raw .#formatter.x86_64-linux.type\n- nix eval --raw .#apps.x86_64-linux.style-check.type

Follow-up pushed: `1cfab7e refactor(nix): expose formatter wrapper in outputs`.\n\nChanged `src/dotfiles/formatter.nix` to return the treefmt evaluation object. `src/dotfiles/default.nix` now uses `formatter.config.build.wrapper` directly for both the flake formatter output and the style-check app input.\n\nVerified:\n- `nix eval --raw .#formatter.x86_64-linux.type`\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`
Author
Owner

Follow-up pushed: 9caf79d refactor(nix): inline style-check app package.\n\nRemoved the one-use styleCheck let binding from src/dotfiles/apps.nix; program now references pkgs.writeShellApplication directly.\n\nVerified:\n- nix eval --raw .#apps.x86_64-linux.style-check.type\n- nix eval --raw .#formatter.x86_64-linux.type

Follow-up pushed: `9caf79d refactor(nix): inline style-check app package`.\n\nRemoved the one-use `styleCheck` let binding from `src/dotfiles/apps.nix`; `program` now references `pkgs.writeShellApplication` directly.\n\nVerified:\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`
Author
Owner

Follow-up pushed: 5271523 fix(nix): make style app check-only.\n\nRoot cause: treefmt --fail-on-change still formats the working tree before returning an error. The app now depends on formatter.config.build.check self instead, so the formatting check runs in the Nix build sandbox and cannot mutate the checkout.\n\nI reverted the formatter changes that nix run .#style-check made in the worktree.\n\nVerified:\n- nix run .#style-check now fails on formatting diffs without changing tracked Nix files\n- nix eval --raw .#apps.x86_64-linux.style-check.type\n- nix eval --raw .#formatter.x86_64-linux.type

Follow-up pushed: `5271523 fix(nix): make style app check-only`.\n\nRoot cause: `treefmt --fail-on-change` still formats the working tree before returning an error. The app now depends on `formatter.config.build.check self` instead, so the formatting check runs in the Nix build sandbox and cannot mutate the checkout.\n\nI reverted the formatter changes that `nix run .#style-check` made in the worktree.\n\nVerified:\n- `nix run .#style-check` now fails on formatting diffs without changing tracked Nix files\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`
Author
Owner

Follow-up pushed: f8b7319 refactor(nix): pass formatter to style app.\n\nRestored the app import shape to pass formatter into apps.nix; the style-check command now uses formatter.config.build.check self directly instead of a poorly named formattingCheck argument.\n\nVerified:\n- nix run .#style-check still fails on existing formatting diffs without mutating the checkout\n- nix eval --raw .#apps.x86_64-linux.style-check.type\n- nix eval --raw .#formatter.x86_64-linux.type

Follow-up pushed: `f8b7319 refactor(nix): pass formatter to style app`.\n\nRestored the app import shape to pass `formatter` into `apps.nix`; the style-check command now uses `formatter.config.build.check self` directly instead of a poorly named `formattingCheck` argument.\n\nVerified:\n- `nix run .#style-check` still fails on existing formatting diffs without mutating the checkout\n- `nix eval --raw .#apps.x86_64-linux.style-check.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`
Author
Owner

Follow-up pushed: caaa53c feat(nix): add style fix app.\n\nChanged the app surface from check-only to mutating as discussed:\n- app name is now fix\n- nix run .#fix runs treefmt, statix fix ., deadnix --edit --no-lambda-pattern-names --no-underscore ., then treefmt again\n- removed the old style-check app\n\nVerified the flake outputs:\n- nix eval --raw .#apps.x86_64-linux.fix.type\n- nix eval --raw .#apps.x86_64-linux.fix.program\n- nix eval --raw .#formatter.x86_64-linux.type\n- nix eval --raw .#apps.x86_64-linux.style-check.type fails, confirming the old app name is gone

Follow-up pushed: `caaa53c feat(nix): add style fix app`.\n\nChanged the app surface from check-only to mutating as discussed:\n- app name is now `fix`\n- `nix run .#fix` runs `treefmt`, `statix fix .`, `deadnix --edit --no-lambda-pattern-names --no-underscore .`, then `treefmt` again\n- removed the old `style-check` app\n\nVerified the flake outputs:\n- `nix eval --raw .#apps.x86_64-linux.fix.type`\n- `nix eval --raw .#apps.x86_64-linux.fix.program`\n- `nix eval --raw .#formatter.x86_64-linux.type`\n- `nix eval --raw .#apps.x86_64-linux.style-check.type` fails, confirming the old app name is gone
Author
Owner

Squashed PR branch as requested.\n\nCurrent branch contains one commit:\n- 6ca431b feat(nix): add style tooling\n\nRe-verified after squash:\n- nix eval --raw .#apps.x86_64-linux.fix.type\n- nix eval --raw .#formatter.x86_64-linux.type

Squashed PR branch as requested.\n\nCurrent branch contains one commit:\n- `6ca431b feat(nix): add style tooling`\n\nRe-verified after squash:\n- `nix eval --raw .#apps.x86_64-linux.fix.type`\n- `nix eval --raw .#formatter.x86_64-linux.type`
Author
Owner

Follow-up pushed: c293cc0 refactor(nix): use default deadnix fixes.\n\nRemoved the assumed deadnix flags from the fix app. It now runs deadnix --edit . so deadnix behavior stays at its defaults instead of encoding assumptions about this repo's lambda args or underscore bindings.\n\nVerified:\n- nix eval --raw .#apps.x86_64-linux.fix.type\n- nix eval --raw .#apps.x86_64-linux.fix.program

Follow-up pushed: `c293cc0 refactor(nix): use default deadnix fixes`.\n\nRemoved the assumed deadnix flags from the fix app. It now runs `deadnix --edit .` so deadnix behavior stays at its defaults instead of encoding assumptions about this repo's lambda args or underscore bindings.\n\nVerified:\n- `nix eval --raw .#apps.x86_64-linux.fix.type`\n- `nix eval --raw .#apps.x86_64-linux.fix.program`
Author
Owner

Follow-up pushed: aafcbc1 fix(nix): exclude generated hardware configs.\n\nDeadnix exclusion details:\n- quoted glob did not protect generated hardware configs during --edit\n- verified working form is shell-expanded paths plus -- before the scan root\n- app now runs deadnix --edit --exclude configs/nixos/hosts/*/hardware-configuration.nix -- .\n\nVerification command run before updating the app:\n- nix shell nixpkgs#deadnix -c deadnix --edit --exclude configs/nixos/hosts/*/hardware-configuration.nix -- .\n\nThat changed only src/dotfiles/registry.nix, not generated hardware configs; I reverted the verification edit afterward.\n\nOutput shape re-verified:\n- nix eval --raw .#apps.x86_64-linux.fix.type\n- nix eval --raw .#apps.x86_64-linux.fix.program

Follow-up pushed: `aafcbc1 fix(nix): exclude generated hardware configs`.\n\nDeadnix exclusion details:\n- quoted glob did not protect generated hardware configs during `--edit`\n- verified working form is shell-expanded paths plus `--` before the scan root\n- app now runs `deadnix --edit --exclude configs/nixos/hosts/*/hardware-configuration.nix -- .`\n\nVerification command run before updating the app:\n- `nix shell nixpkgs#deadnix -c deadnix --edit --exclude configs/nixos/hosts/*/hardware-configuration.nix -- .`\n\nThat changed only `src/dotfiles/registry.nix`, not generated hardware configs; I reverted the verification edit afterward.\n\nOutput shape re-verified:\n- `nix eval --raw .#apps.x86_64-linux.fix.type`\n- `nix eval --raw .#apps.x86_64-linux.fix.program`
alexion added 1 commit 2026-09-16 00:13:45 -04:00
alexion force-pushed setup-nix-style-tools from aafcbc1179 to d24f58a4c9 2026-09-16 00:13:45 -04:00 Compare
Author
Owner

Squashed PR branch after reverting the deadnix test edit.\n\nCurrent branch contains one commit:\n- d24f58a feat(nix): add style tooling\n\nRe-verified after squash:\n- nix eval --raw .#apps.x86_64-linux.fix.type\n- nix eval --raw .#apps.x86_64-linux.fix.program\n- nix eval --raw .#formatter.x86_64-linux.type

Squashed PR branch after reverting the deadnix test edit.\n\nCurrent branch contains one commit:\n- `d24f58a feat(nix): add style tooling`\n\nRe-verified after squash:\n- `nix eval --raw .#apps.x86_64-linux.fix.type`\n- `nix eval --raw .#apps.x86_64-linux.fix.program`\n- `nix eval --raw .#formatter.x86_64-linux.type`
alexion merged commit d24f58a4c9 into main 2026-09-16 00:14:11 -04:00
alexion deleted branch setup-nix-style-tools 2026-09-16 00:14:12 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alexion/dev#52