From 7bb5b68ab683fc1801e767966e5f502673b2959a Mon Sep 17 00:00:00 2001 From: 514fpv Date: Mon, 13 Jan 2025 11:01:20 +0800 Subject: [PATCH] feat(flake): add treefmt --- flake.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index d50b4480..4acee0c6 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,7 @@ flake-utils.url = "github:numtide/flake-utils"; flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; + treefmt-nix.url = "github:numtide/treefmt-nix"; impermanence.url = "github:nix-community/impermanence/master"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; @@ -20,9 +21,18 @@ jovian.url = "github:Jovian-Experiments/Jovian-NixOS"; }; - outputs = inputs: - inputs.flake-parts.lib.mkFlake + outputs = inputs@{self, flake-parts, treefmt-nix,...}: + flake-parts.lib.mkFlake { inherit inputs; } { + perSystem = {pkgs, ...}: let + treefmtEval = treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + }; + in { + formatter = treefmtEval.config.build.wrapper; + checks.formatting = treefmtEval.config.build.check self; + }; systems = [ "x86_64-linux" ];