[FEATURE]: Add nixfmt formatter for Nix files #3971

Closed
opened 2026-02-16 17:42:08 -05:00 by yindo · 1 comment
Owner

Originally created by @anntnzrb on GitHub (Dec 29, 2025).

Originally assigned to: @thdxr on GitHub.

Summary

Add support for nixfmt as a built-in formatter for .nix files.

Context

  • nixfmt is the official Nix formatter (RFC 166)
  • OpenCode already has LSP support for Nix via nixd, but no formatter
  • As of NixOS 25.11, pkgs.nixfmt is the stable RFC-style formatter

Proposed Solution

Add nixfmt to the built-in formatters following the existing pattern (like gofmt, gleam, shfmt):

  • Extensions: .nix
  • Command: nixfmt $FILE
  • Enabled when nixfmt is available in PATH
Originally created by @anntnzrb on GitHub (Dec 29, 2025). Originally assigned to: @thdxr on GitHub. ## Summary Add support for `nixfmt` as a built-in formatter for `.nix` files. ## Context - `nixfmt` is the official Nix formatter (RFC 166) - OpenCode already has LSP support for Nix via `nixd`, but no formatter - As of NixOS 25.11, `pkgs.nixfmt` is the stable RFC-style formatter ## Proposed Solution Add `nixfmt` to the built-in formatters following the existing pattern (like `gofmt`, `gleam`, `shfmt`): - Extensions: `.nix` - Command: `nixfmt $FILE` - Enabled when `nixfmt` is available in PATH
yindo added the nix label 2026-02-16 17:42:08 -05:00
yindo closed this issue 2026-02-16 17:42:08 -05:00
Author
Owner

@anntnzrb commented on GitHub (Dec 29, 2025):

PR: #6380

@anntnzrb commented on GitHub (Dec 29, 2025): PR: #6380
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3971