From 574b4e4651495ed3fb14ef53a00374782d45b378 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Thu, 24 Sep 2026 04:11:00 +0530 Subject: feat(flake): add lua and shell formatters to nix fmt --- flake.nix | 30 +++++++++++++++++++++++++--- modules/file-management/yazi/file-chooser.sh | 4 ++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 5fe9747..d2d305d 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,10 @@ url = "github:cachix/git-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; nixConfig = { @@ -35,6 +39,7 @@ home-manager, nixvim, git-hooks, + treefmt-nix, ... }: let @@ -44,10 +49,26 @@ inherit pkgs; lib = pkgs.lib; }; + + treefmtEval = treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; + stylua.enable = true; + shfmt = { + enable = true; + indent_size = 2; + }; + }; + }; + preCommitCheck = git-hooks.lib.${system}.run { src = ./.; hooks = { - nixfmt.enable = true; + treefmt = { + enable = true; + package = treefmtEval.config.build.wrapper; + }; forbid-private = { enable = true; name = "Forbid committing private files"; @@ -76,8 +97,11 @@ type = "app"; program = "${updates}/bin/updates"; }; - formatter.${system} = pkgs.nixfmt-tree; - checks.${system}.pre-commit-check = preCommitCheck; + formatter.${system} = treefmtEval.config.build.wrapper; + checks.${system} = { + pre-commit-check = preCommitCheck; + formatting = treefmtEval.config.build.check self; + }; devShells.${system}.default = pkgs.mkShell { inherit (preCommitCheck) shellHook; buildInputs = preCommitCheck.enabledPackages ++ [ diff --git a/modules/file-management/yazi/file-chooser.sh b/modules/file-management/yazi/file-chooser.sh index 788a5d9..bb5c7cc 100644 --- a/modules/file-management/yazi/file-chooser.sh +++ b/modules/file-management/yazi/file-chooser.sh @@ -18,6 +18,6 @@ if [ "$directory" = "1" ]; then # Outputs the final working directory path on exit exec yazi "$path" --cwd-file="$out" else - # Writes all selected file paths to the output file on exit - exec yazi "$path" --chooser-file="$out" + # Writes all selected file paths to the output file on exit + exec yazi "$path" --chooser-file="$out" fi -- cgit v1.2.3