-
Notifications
You must be signed in to change notification settings - Fork 463
/
purty.nix
42 lines (41 loc) · 1.32 KB
/
purty.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ runCommand, purty, src, lib, diffutils, glibcLocales }:
let
# just purescript sources
src' = lib.cleanSourceWith {
inherit src;
filter = with lib;
name: type: let baseName = baseNameOf (toString name); in (
(type == "regular" && hasSuffix ".purs" baseName) ||
(type == "directory" && (baseName != "generated"
&& baseName != "output"
&& baseName != "node_modules"
&& baseName != ".psc-package"
&& baseName != ".spago"))
);
};
in
runCommand "purty-check" {
buildInputs = [ purty diffutils glibcLocales ];
} ''
set +e
cp -a ${src'} orig
cp -a ${src'} purty
chmod -R +w purty
cd purty
find . -type f -name "*.purs" -exec ${purty}/bin/purty --write {} \;
cd ..
diff --brief --recursive orig purty > /dev/null
EXIT_CODE=$?
if [[ $EXIT_CODE != 0 ]]
then
mkdir -p $out/nix-support
diff -ur orig purty > $out/purty.diff
echo "file none $out/purty.diff" > $out/nix-support/hydra-build-products
echo "*** purty-haskell found changes that need addressed first"
echo "*** Please run \`nix-shell --run fix-purty\` and commit changes"
echo "*** or apply the diff generated by hydra if you don't have nix."
exit $EXIT_CODE
else
echo $EXIT_CODE > $out
fi
''