@@ -25,8 +25,10 @@ usage:
2525 @echo " ghci -- Run cabal v2-repl bot-plutus-interface"
2626 @echo " format -- Apply source code formatting with fourmolu"
2727 @echo " format_check -- Check source code formatting without making changes"
28- @echo " nixfmt -- Apply nix formatting with nixfmt"
29- @echo " nixfmt_check -- Check nix files for format errors"
28+ @echo " cabalfmt -- Apply cabal formatting with cabal-fmt"
29+ @echo " cabalfmt_check -- Check cabal files for formatting errors without making changes"
30+ @echo " nixpkgsfmt -- Apply nix formatting with nixfmt"
31+ @echo " nixpkgsfmt_check -- Check nix files for format errors"
3032 @echo " lint -- Check the sources with hlint"
3133 @echo " readme_contents -- Add table of contents to README"
3234 @echo " update_plutus -- Update plutus version with niv"
@@ -68,7 +70,7 @@ ghci: requires_nix_shell
6870 cabal v2-repl $(GHC_FLAGS ) bot-plutus-interface
6971
7072# Source dirs to run fourmolu on
71- FORMAT_SOURCES := $(shell git ls-tree -r HEAD --full-tree --name-only | grep -E '. * \.hs' )
73+ FORMAT_SOURCES := $(shell fd -e hs )
7274
7375# Extensions we need to tell fourmolu about
7476FORMAT_EXTENSIONS := -o -XTemplateHaskell -o -XTypeApplications -o -XImportQualifiedPost -o -XPatternSynonyms -o -fplugin=RecordDotPreprocessor
@@ -81,14 +83,23 @@ format: requires_nix_shell
8183format_check : requires_nix_shell
8284 fourmolu --mode check --check-idempotence $(FORMAT_EXTENSIONS ) $(FORMAT_SOURCES )
8385
86+ # Cabal package definitions
87+ CABAL_SOURCES := $(shell fd -e cabal)
88+
89+ cabalfmt : requires_nix_shell
90+ cabal-fmt --inplace $(CABAL_SOURCES )
91+
92+ cabalfmt_check : requires_nix_shell
93+ cabal-fmt --check $(CABAL_SOURCES )
94+
8495# Nix files to format
85- NIX_SOURCES := $(shell git ls-tree -r HEAD --full-tree --name-only | grep -E '. * \. nix' )
96+ NIX_SOURCES := $(shell fd -e nix)
8697
87- nixfmt : requires_nix_shell
88- nixfmt $(NIX_SOURCES )
98+ nixpkgsfmt : requires_nix_shell
99+ nixpkgs-fmt $(NIX_SOURCES )
89100
90- nixfmt_check : requires_nix_shell
91- nixfmt --check $(NIX_SOURCES )
101+ nixpkgsfmt_check : requires_nix_shell
102+ nixpkgsfmt --check $(NIX_SOURCES )
92103
93104# Check with hlint, currently I couldn't get --refactor to work
94105lint : requires_nix_shell
@@ -124,4 +135,3 @@ update_plutus:
124135build_path = dist-newstyle/build/x86_64-linux/ghc-8.10.4.20210212/bot-plutus-interface-0.1
125136clear_build :
126137 @[ ! -e $( build_path) ] || rm -rf $(build_path )
127-
0 commit comments