feat(flake): add treefmt for formatting all files

This commit is contained in:
Reed Krantz
2026-02-18 18:14:12 -06:00
parent 6be48da010
commit 35e34c27f7
8 changed files with 46 additions and 13 deletions

View File

@@ -6,6 +6,11 @@
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
rust-overlay = {
@@ -17,11 +22,16 @@
outputs = {
nixpkgs,
flake-parts,
treefmt-nix,
crane,
rust-overlay,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
treefmt-nix.flakeModule
];
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {system, ...}: let
@@ -71,7 +81,13 @@
};
# Formatter for nix files, available through 'nix fmt'
formatter = pkgs.alejandra;
treefmt = {
programs.alejandra.enable = true;
programs.rustfmt = {
enable = true;
edition = (builtins.fromTOML (builtins.readFile "${src}/Cargo.toml")).package.edition;
};
};
# Your custom packages
# Accessible through 'nix build', 'nix shell', 'nix run', etc
@@ -86,10 +102,6 @@
inherit src buildInputs nativeBuildInputs cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
};
fmt = craneLib.cargoFmt {
inherit src buildInputs nativeBuildInputs;
};
};
};
};