Files
postgrest/nix/devtools.nix
T
Remo RechkemmerandGitHub 48c9ac36b1 Bump nixpkgs and simplify/clean up nix setup (#1529)
* Refactor tests and fix README

* fix linting hints from new hlint version

* postgrest-style with new nixpkgs-fmt
2020-05-20 21:30:20 -05:00

50 lines
1.1 KiB
Nix

{ writeShellScriptBin
, buildEnv
, git
, hlint
, nixpkgs-fmt
, silver-searcher
, stylish-haskell
}:
let
style =
writeShellScriptBin "postgrest-style"
''
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
# Format Haskell files
${silver-searcher}/bin/ag -l -g '\.l?hs$' "$rootdir" \
| xargs ${stylish-haskell}/bin/stylish-haskell -i
'';
check =
writeShellScriptBin "postgrest-style-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
'';
in
buildEnv {
name = "postgrest-devtools";
paths = [ style check lint ];
}