nix: set up project-wide formatter
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4806c58aa0a17f504c9312723ad770166a6a6964
This commit is contained in:
parent
aa9c55277c
commit
9e5eb41d39
78 changed files with 7406 additions and 2504 deletions
33
flake.nix
33
flake.nix
|
|
@ -21,5 +21,38 @@
|
|||
in {
|
||||
default = pkgs.callPackage ./nix/shell.nix {};
|
||||
});
|
||||
|
||||
formatter = forEachSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "nix3-fmt-wrapper";
|
||||
|
||||
runtimeInputs = [
|
||||
pkgs.alejandra
|
||||
pkgs.fd
|
||||
pkgs.prettier
|
||||
pkgs.deno
|
||||
pkgs.taplo
|
||||
pkgs.sql-formatter
|
||||
];
|
||||
|
||||
text = ''
|
||||
# Format Nix with Alejandra
|
||||
fd "$@" -t f -e nix -x alejandra -q '{}'
|
||||
|
||||
# Format TOML with Taplo
|
||||
fd "$@" -t f -e toml -x taplo fmt '{}'
|
||||
|
||||
# Format CSS with Prettier
|
||||
fd "$@" -t f -e css -x prettier --write '{}'
|
||||
|
||||
# Format SQL with sql-format
|
||||
fd "$@" -t f -e sql -x sql-formatter --fix '{}' -l postgresql
|
||||
|
||||
# Format Markdown with Deno
|
||||
fd "$@" -t f -e md -x deno fmt -q '{}'
|
||||
'';
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue