From bc163b8157639ab143fddd6d44023190432f8fd9 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 30 Jul 2025 01:16:58 +0800 Subject: [PATCH] feat: replace alejandra with nixfmt(rfc-style) 1.0.0 --- flake.nix | 2 +- .../tui/editors/neovim/nvim/lua/plugins/none-ls.lua | 2 +- home/base/tui/editors/packages.nix | 2 +- outputs/default.nix | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index e4cb6c5f..07c6711a 100644 --- a/flake.nix +++ b/flake.nix @@ -109,7 +109,7 @@ # add git hooks to format nix code before commit pre-commit-hooks = { - url = "github:cachix/pre-commit-hooks.nix"; + url = "github:cachix/git-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; diff --git a/home/base/tui/editors/neovim/nvim/lua/plugins/none-ls.lua b/home/base/tui/editors/neovim/nvim/lua/plugins/none-ls.lua index e3cd1941..b0ae6e34 100644 --- a/home/base/tui/editors/neovim/nvim/lua/plugins/none-ls.lua +++ b/home/base/tui/editors/neovim/nvim/lua/plugins/none-ls.lua @@ -39,7 +39,7 @@ return { formatting.shfmt, -- Shell formatter formatting.terraform_fmt, -- Terraform formatter formatting.stylua, -- Lua formatter - formatting.alejandra, -- Nix formatter + -- formatting.alejandra, -- Nix formatter formatting.sqlfluff.with { -- SQL formatter extra_args = { "--dialect", "postgres" }, -- change to your dialect }, diff --git a/home/base/tui/editors/packages.nix b/home/base/tui/editors/packages.nix index abb12bfc..c2b4e90c 100644 --- a/home/base/tui/editors/packages.nix +++ b/home/base/tui/editors/packages.nix @@ -11,7 +11,7 @@ nixd statix # Lints and suggestions for the nix programming language deadnix # Find and remove unused code in .nix source files - alejandra # Nix Code Formatter + nixfmt # Nix Code Formatter #-- nickel lang nickel diff --git a/outputs/default.nix b/outputs/default.nix index 9bc6022f..895c4313 100644 --- a/outputs/default.nix +++ b/outputs/default.nix @@ -104,7 +104,10 @@ in { pre-commit-check = pre-commit-hooks.lib.${system}.run { src = mylib.relativeToRoot "."; hooks = { - alejandra.enable = true; # formatter + nixfmt-rfc-style = { + enable = true; + settings.width = 100; + }; # Source code spell checker typos = { enable = true; @@ -139,7 +142,7 @@ in { # fix `cc` replaced by clang, which causes nvim-treesitter compilation error gcc # Nix-related - alejandra + nixfmt deadnix statix # spell checker @@ -157,7 +160,6 @@ in { # Format the nix code in this flake formatter = forAllSystems ( - # alejandra is a nix formatter with a beautiful output - system: nixpkgs.legacyPackages.${system}.alejandra + system: nixpkgs.legacyPackages.${system}.nixfmt ); }