chore(fmt): wire nix fmt to treefmt

Use treefmt-nix with nixfmt, statix, and deadnix so nix fmt applies formatting and auto-fixes in one pass.
This commit is contained in:
anntnzrb
2026-02-04 23:30:58 -05:00
committed by mjallen18
parent 9b9398b53f
commit 797700f47a
2 changed files with 50 additions and 7 deletions

View File

@@ -4,6 +4,10 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus/master";
treefmt-nix = {
url = "github:numtide/treefmt-nix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
@@ -15,6 +19,28 @@
core-inputs = inputs // {
src = self;
};
systems = inputs.nixpkgs.lib.systems.flakeExposed;
inherit (inputs.flake-utils-plus.lib) eachSystemMap;
treefmtEval = eachSystemMap systems (
system:
inputs.treefmt-nix.lib.evalModule inputs.nixpkgs.legacyPackages.${system} {
projectRootFile = "flake.nix";
programs = {
deadnix = {
enable = true;
no-lambda-arg = false;
no-lambda-pattern-names = false;
no-underscore = false;
};
nixfmt.enable = true;
statix = {
enable = true;
disabled-lints = [ ];
};
};
}
);
# Create the library, extending the nixpkgs library and merging
# libraries from other inputs to make them available like
@@ -59,12 +85,7 @@
user = ./modules/home/user/default.nix;
};
formatter = {
x86_64-linux = inputs.nixpkgs.legacyPackages.x86_64-linux.nixfmt-tree;
aarch64-linux = inputs.nixpkgs.legacyPackages.aarch64-linux.nixfmt-tree;
x86_64-darwin = inputs.nixpkgs.legacyPackages.x86_64-darwin.nixfmt-tree;
aarch64-darwin = inputs.nixpkgs.legacyPackages.aarch64-darwin.nixfmt-tree;
};
formatter = eachSystemMap systems (system: treefmtEval.${system}.config.build.wrapper);
snowfall = rec {
raw-config = config;