nix: configure default formatter for nix fmt
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia75cd29276e4eed2d57a37e02281d48b6a6a6964
This commit is contained in:
parent
2ef2dabf93
commit
de959ec22b
1 changed files with 28 additions and 0 deletions
28
flake.nix
28
flake.nix
|
|
@ -18,6 +18,34 @@
|
|||
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {};
|
||||
});
|
||||
|
||||
formatter = forEachSystem (system: let
|
||||
pkgs = pkgsForEach.${system};
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "nix3-fmt-wrapper";
|
||||
runtimeInputs = [
|
||||
pkgs.alejandra
|
||||
pkgs.fd
|
||||
pkgs.prettier
|
||||
pkgs.go # provides gofmt
|
||||
pkgs.golines
|
||||
];
|
||||
|
||||
text = ''
|
||||
# Format Nix files with Alejandra
|
||||
fd "$@" -t f -e nix -x alejandra -q '{}'
|
||||
|
||||
# Format HTML & Javascript files with Prettier
|
||||
fd "$@" -t f -e html -e js -x prettier -w '{}'
|
||||
|
||||
# Format go files with both gofmt & golines
|
||||
fd "$@" -t f -e go -x golines -l -w --max-len=110 \
|
||||
--base-formatter=gofmt \
|
||||
--shorten-comments \
|
||||
--ignored-dirs=.direnv '{}'
|
||||
'';
|
||||
});
|
||||
|
||||
nixosModules = {
|
||||
watchdog = import ./nix/module.nix self;
|
||||
default = self.nixosModules.watchdog;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue