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

24
flake.lock generated
View File

@@ -56,7 +56,8 @@
"root": {
"inputs": {
"flake-utils-plus": "flake-utils-plus",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
}
},
"systems": {
@@ -73,6 +74,27 @@
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1770228511,
"narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "337a4fe074be1042a35086f15481d763b8ddc0e7",
"type": "github"
},
"original": {
"owner": "numtide",
"ref": "main",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",

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;