diff --git a/flake.lock b/flake.lock index d5adb02..60889f8 100644 --- a/flake.lock +++ b/flake.lock @@ -58,7 +58,8 @@ "crane": "crane", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "rust-overlay": "rust-overlay", + "treefmt-nix": "treefmt-nix" } }, "rust-overlay": { @@ -95,6 +96,26 @@ "repo": "default", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723808491, + "narHash": "sha256-rhis3qNuGmJmYC/okT7Dkc4M8CeUuRCSvW6kC2f3hBc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "1d07739554fdc4f8481068f1b11d6ab4c1a4167a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4ad97c2..23bdd4f 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,10 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; @@ -14,7 +18,8 @@ }; }; - outputs = { self, nixpkgs, flake-utils, crane, rust-overlay, ... }: + outputs = + { self, nixpkgs, flake-utils, treefmt-nix, crane, rust-overlay, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { @@ -23,6 +28,20 @@ }; inherit (pkgs) lib; + treefmt = treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs = { + deadnix.enable = true; + nixfmt = { + enable = true; + package = pkgs.nixfmt-classic; + }; + prettier.enable = true; + statix.enable = true; + taplo.enable = true; + }; + }; + rustToolchain = pkgs.rust-bin.stable.latest.default.override { extensions = [ "rust-analyzer" ]; }; @@ -63,6 +82,7 @@ checks = { inherit bwtui; default = bwtui; + formatting = treefmt.config.build.check self; bwtui-clippy = craneLib.cargoClippy commonArgsWithArtifacts // { cargoClippyExtraArgs = "--all-targets -- --deny warnings"; }; @@ -73,6 +93,8 @@ bwtui-coverage = craneLib.cargoTarpaulin commonArgsWithArtifacts; }; + formatter = treefmt.config.build.wrapper; + packages = rec { inherit bwtui; default = bwtui;