Improve dev tools in the Nix environment (#1666)

* Improve dev tools in the nix environment

Added postgrest-build, postgrest-run, postgrest-clean, postgrest-check
and postgrest-watch tools. Changed order of postgrest-test-spec-all to
run backwards from pg13 to pg9.5. Added shellcheck to lint shell scripts
in nix environment.

Co-authored-by: monacoremo <monacoremo>
This commit is contained in:
Remo Rechkemmer
2020-11-30 22:21:19 +01:00
committed by GitHub
co-authored by monacoremo <monacoremo>
parent 9adec12a67
commit 07cb47e6ac
13 changed files with 255 additions and 129 deletions
+42 -32
View File
@@ -1,49 +1,59 @@
{ writeShellScriptBin
, buildEnv
{ buildEnv
, cabal-install
, checkedShellScript
, devCabalOptions
, entr
, git
, hlint
, nixpkgs-fmt
, silver-searcher
, stylish-haskell
, style
, tests
}:
let
style =
writeShellScriptBin "postgrest-style"
watch =
checkedShellScript "postgrest-watch"
''
set -euo pipefail
rootdir="$(${git}/bin/git rev-parse --show-toplevel)"
# Format Nix files
${nixpkgs-fmt}/bin/nixpkgs-fmt "$rootdir" > /dev/null 2> /dev/null
${silver-searcher}/bin/ag -l . "$rootdir" | ${entr}/bin/entr -r "$@"
'';
# Format Haskell files
${silver-searcher}/bin/ag -l -g '\.l?hs$' "$rootdir" \
| xargs ${stylish-haskell}/bin/stylish-haskell -i
pushCachix =
checkedShellScript "postgrest-push-cachix"
''
nix-store -qR --include-outputs "$(nix-instantiate)" \
| cachix push postgrest
'';
build =
checkedShellScript "postgrest-build"
''exec ${cabal-install}/bin/cabal v2-build ${devCabalOptions} "$@"'';
run =
checkedShellScript "postgrest-run"
''exec ${cabal-install}/bin/cabal v2-run postgrest ${devCabalOptions} -- "$@"'';
clean =
checkedShellScript "postgrest-clean"
''
${cabal-install}/bin/cabal v2-clean
'';
check =
writeShellScriptBin "postgrest-style-check"
checkedShellScript "postgrest-check"
''
set -euo pipefail
${style}/bin/${style.name}
${git}/bin/git diff-index --exit-code HEAD -- '*.hs' '*.lhs' '*.nix'
'';
lint =
writeShellScriptBin "postgrest-lint"
''
set -euo pipefail
rootdir="$(${git}/bin/git rev-parse --show-toplevel)"
# Lint Haskell files
${silver-searcher}/bin/ag -l -g '\.l?hs$' "$rootdir" \
| xargs ${hlint}/bin/hlint -X QuasiQuotes -X NoPatternSynonyms
${tests}/bin/postgrest-test-spec-all
${style}/bin/postgrest-lint
${style}/bin/postgrest-style-check
'';
in
buildEnv {
name = "postgrest-devtools";
paths = [ style check lint ];
paths = [
watch.bin
pushCachix.bin
build.bin
run.bin
clean.bin
check.bin
];
}