Skip to content

Update Nix formatter#1766

Open
lucperkins wants to merge 1 commit intomainfrom
update-formatter
Open

Update Nix formatter#1766
lucperkins wants to merge 1 commit intomainfrom
update-formatter

Conversation

@lucperkins
Copy link
Member

@lucperkins lucperkins commented Feb 11, 2026

This updates the installer repo to use the official Nix formatter rather than nixpkgs-fmt.

Summary by CodeRabbit

  • Chores
    • Migrated Nix formatting checks from nixpkgs-fmt to nixfmt across the CI pipeline and build infrastructure.
    • Added a new format-nix tool for Nix code formatting.
    • Refactored internal build configuration and test harness structure for improved organization.

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

This pull request refactors Nix configuration files to modernize the build toolchain and structure. The formatter is switched from nixpkgs-fmt to nixfmt, with corresponding check updates. The flake.nix outputs structure is rewritten and expanded. Tests and check definitions are reformatted for consistency.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/ci.yml
Updated Nix formatting check step: renamed from "Check nixpkgs-fmt formatting" to "Check Nix formatting" and changed command from check-nixpkgs-fmt to check-nixfmt.
Nix Check Definitions
nix/check.nix
Removed check-nixpkgs-fmt and introduced check-nixfmt and format-nix checks using nixfmt. Reformatted existing check definitions (check-rustfmt, check-spelling, check-editorconfig, check-semver, check-clippy) to multi-line parenthesized form.
Flake Configuration
flake.nix
Substantial restructuring: reformatted outputs function signature; expanded supportedSystems and system lists; rewrote forSystem function; restructured installerPackage, devShells, checks, packages, and formatter definitions to use consistent per-system patterns; switched formatter from nixpkgs-fmt to nixfmt.
Container Tests
nix/tests/container-test/default.nix
Refactored makeTest and container-tests with explicit let...in structure and reformatted mapAttrs lambda blocks. Consolidated release tool aggregation blocks to parenthesized forms without functional changes.
VM Tests
nix/tests/vm-test/default.nix
Reformatted public parameter blocks, string concatenation, and makeTest definitions to explicit let...in structure. Expanded buildInputs across multiple lines and adjusted mapAttrs layout without altering runtime behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • grahamc
  • colemickens

Poem

🐰 Whiskers twitch as nixfmt's here,
Old tools fade, the path grows clear,
Flakes refactored, checks refined,
Nix files structured, better aligned!
A hop towards tomorrow's glow.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update Nix formatter' directly corresponds to the main objective of replacing nixpkgs-fmt with nixfmt across the repository.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-formatter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@flake.nix`:
- Line 221: The flake references pkgs.nixfmt which does not exist in the pinned
nixpkgs; update the formatter entry to use the available pkgs.nixfmt-classic
(replace pkgs.nixfmt with pkgs.nixfmt-classic in the formatter = forAllSystems
({ pkgs, ... }: ...) expression) or alternatively update the pinned nixpkgs
revision to one that provides pkgs.nixfmt; ensure the change targets the
formatter declaration that uses forAllSystems and pkgs.

}
);

formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check nixfmt references and examine flake.lock for nixpkgs revision
rg -n 'nixfmt' flake.nix flake.lock
echo "---"
echo "Checking flake.lock for nixpkgs revision:"
rg -A5 '"nixpkgs"' flake.lock | head -20

Repository: DeterminateSystems/nix-installer

Length of output: 838


🌐 Web query:

nixpkgs nixfmt RFC 166 package naming 2025 2026

💡 Result:

  • RFC 166 is about standardizing Nix code formatting and establishing the Nix Formatting Team (which maintains the official formatter, nixfmt)—it’s not the RFC that defines nixpkgs package naming rules. [1]
  • nixfmt in nixpkgs (naming / rollout timeline):
    • The RFC-style formatter landed in nixpkgs as nixfmt-rfc-style (testing call posted 2024-02-02). [2]
    • Formatting enforcement in nixpkgs CI was announced 2024-07-23, using nixfmt pinned in the nixpkgs dev environment. [3]
    • A full tree-wide nixpkgs reformat PR was opened 2025-02-10, with a merge-party date noted as 2025-04-01. [4]
    • nixfmt v1.0.0 (first stable release) was announced 2025-07-14. [5]
    • The long-term plan was to rename nixfmt-rfc-stylenixfmt, and by NixOS 25.11 nixpkgs provides the official formatter as pkgs.nixfmt-rfc-style and pkgs.nixfmt. [6]
  • nixpkgs package naming conventions (separate from RFC 166):
    • nixpkgs manual guidelines: generally follow upstream names, keep names lowercase, preserve dashes, and for “unstable” snapshots use pkgname-unstable-YYYY-MM-DD. [7]
    • Wiki conventions for common suffixes (examples): -bin, -unwrapped. [8]

Sources:
[1] https://nixos.org/community/teams/formatting/
[2] https://discourse.nixos.org/t/call-for-testing-nix-formatter/39179
[3] https://discourse.nixos.org/t/enforcing-nix-formatting-in-nixpkgs/49506
[4] https://discourse.nixos.org/t/nix-formatting-team-full-nixpkgs-reformat/61867
[5] https://discourse.nixos.org/t/nixfmt-1-0-0-is-out/66537
[6] https://hackage.haskell.org/package/nixfmt
[7] https://releases.nixos.org/nixpkgs/nixpkgs-17.03pre90950.3ddf76c/manual/epub/OEBPS/ch10s02.html
[8] https://wiki.nixos.org/wiki/Package_naming_conventions


🏁 Script executed:

#!/bin/bash
# Extract the full nixpkgs revision from flake.lock
cat flake.lock | jq '.nodes.nixpkgs.locked' 2>/dev/null || rg -A10 '"nixpkgs"' flake.lock | grep -E '"rev"|"narHash"' | head -5

Repository: DeterminateSystems/nix-installer

Length of output: 444


🏁 Script executed:

#!/bin/bash
# Check nixpkgs repository at the specific revision for nixfmt package
# The revision is: daf6dc47aa4b44791372d6139ab7b25269184d55

# Try to fetch nixfmt package info from that nixpkgs revision
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/tools/nix/nixfmt-rfc-style/default.nix" > /dev/null 2>&1 && echo "nixfmt-rfc-style exists" || echo "Could not verify"

# Also check if there's a nixfmt alias or direct package
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/tools/formatting/nixfmt/default.nix" > /dev/null 2>&1 && echo "nixfmt direct exists" || echo "Could not verify"

# Try to check all-packages.nix for nixfmt references around that revision
echo "Checking all-packages.nix for nixfmt entries..."
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -i "nixfmt" | head -10

Repository: DeterminateSystems/nix-installer

Length of output: 215


🏁 Script executed:

#!/bin/bash
# Check what nixfmt refers to in all-packages.nix at that revision
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -A2 "^\s*nixfmt\s*=" | head -10

Repository: DeterminateSystems/nix-installer

Length of output: 58


🏁 Script executed:

#!/bin/bash
# Search more broadly in all-packages.nix for any nixfmt definitions
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -E "nixfmt" | head -20

Repository: DeterminateSystems/nix-installer

Length of output: 122


🏁 Script executed:

#!/bin/bash
# Check the nixfmt-rfc-style package definition
echo "=== Checking nixfmt-rfc-style/default.nix ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/tools/nix/nixfmt-rfc-style/default.nix" 2>/dev/null | head -20

echo ""
echo "=== Checking for nixfmt package/alias in tools/nix ==="
curl -s "https://api.github.com/repos/NixOS/nixpkgs/contents/pkgs/tools/nix?ref=daf6dc47aa4b44791372d6139ab7b25269184d55" 2>/dev/null | grep -E '"name".*nixfmt' | head -10

echo ""
echo "=== Broader search in all-packages.nix for nixfmt references ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -B2 -A2 "nixfmt" | head -20

Repository: DeterminateSystems/nix-installer

Length of output: 466


🏁 Script executed:

#!/bin/bash
# The curl check said "nixfmt direct exists" but 404 suggests it doesn't
# Let me verify the curl result and check haskellPackages approach

echo "=== Verifying nixfmt-rfc-style path ==="
curl -I "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/tools/nix/nixfmt-rfc-style/default.nix" 2>/dev/null | head -5

echo ""
echo "=== List all in pkgs/tools/nix directory ==="
curl -s "https://api.github.com/repos/NixOS/nixpkgs/contents/pkgs/tools/nix?ref=daf6dc47aa4b44791372d6139ab7b25269184d55" 2>/dev/null | jq -r '.[] | select(.type=="dir") | .name' | grep -i nix

echo ""
echo "=== Check for nixfmt in formatting tools ==="
curl -s "https://api.github.com/repos/NixOS/nixpkgs/contents/pkgs/tools/formatting?ref=daf6dc47aa4b44791372d6139ab7b25269184d55" 2>/dev/null | jq -r '.[] | .name' | grep -i nix

Repository: DeterminateSystems/nix-installer

Length of output: 535


🏁 Script executed:

#!/bin/bash
# Simpler approach: search all-packages.nix file content for nixfmt definitions
echo "=== Full nixfmt search in all-packages.nix ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -n "nixfmt" -i

echo ""
echo "=== Check if there's a aliases or re-exports ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -E "^\s+nix" | grep -i fmt | head -10

echo ""
echo "=== Direct check of the file size and structure around nixfmt ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | wc -l

Repository: DeterminateSystems/nix-installer

Length of output: 345


🏁 Script executed:

#!/bin/bash
# Check the context around line 16526 to understand the nixfmt situation better
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | sed -n '16520,16535p'

echo ""
echo "=== Search for any nixfmt without hyphen in all-packages ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -E "^\s+nixfmt\s*=" 

echo ""
echo "=== Check haskellPackages definitions for nixfmt ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/haskell-packages.nix" 2>/dev/null | grep -i "nixfmt" | head -5

Repository: DeterminateSystems/nix-installer

Length of output: 861


🏁 Script executed:

#!/bin/bash
# Final verification: does pkgs.nixfmt even exist as a valid reference?
# Check if there's any nixfmt (without -classic) defined anywhere
echo "=== Final search: nixfmt definitions without -classic ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -n "nixfmt[^-]" | head -10

echo ""
echo "=== Check if nixfmt is imported from another file ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | head -100 | grep -E "import|include" | head -10

echo ""
echo "=== Explicit check: is there a plain 'nixfmt' key at all? ==="
curl -s "https://raw.githubusercontent.com/NixOS/nixpkgs/daf6dc47aa4b44791372d6139ab7b25269184d55/pkgs/top-level/all-packages.nix" 2>/dev/null | grep -oE "^\s+nixfmt\s" | head -5

Repository: DeterminateSystems/nix-installer

Length of output: 383


pkgs.nixfmt does not exist in the pinned nixpkgs revision.

At the pinned nixpkgs revision (daf6dc47aa4b44791372d6139ab7b25269184d55, Sept 2025), only nixfmt-classic is defined in pkgs. The formatter output references pkgs.nixfmt which will cause an evaluation error. Use pkgs.nixfmt-classic instead or update to a nixpkgs revision that provides pkgs.nixfmt as an alias to the RFC formatter.

🤖 Prompt for AI Agents
In `@flake.nix` at line 221, The flake references pkgs.nixfmt which does not exist
in the pinned nixpkgs; update the formatter entry to use the available
pkgs.nixfmt-classic (replace pkgs.nixfmt with pkgs.nixfmt-classic in the
formatter = forAllSystems ({ pkgs, ... }: ...) expression) or alternatively
update the pinned nixpkgs revision to one that provides pkgs.nixfmt; ensure the
change targets the formatter declaration that uses forAllSystems and pkgs.

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

Comments