summaryrefslogtreecommitdiff
path: root/build.nix.sh
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-11-22 08:47:55 -0500
committerBen Gamari <ben@smart-cactus.org>2017-11-22 08:49:26 -0500
commit360d7404809b3fa54541f7f932a6864294f75a4a (patch)
tree49a33f926522faeca5633f5241badf3e410b4717 /build.nix.sh
parentc1fcd9b3f60e8420dd228cd4e3efeb9cfa793aa5 (diff)
downloadhaskell-360d7404809b3fa54541f7f932a6864294f75a4a.tar.gz
Squashed 'hadrian/' changes from fa3771fe6b..4499b294e4
4499b294e4 Follow GHC changes 8fd68186b2 Add ways to build hadrian using nix e5c7a29c23 Do not depend on the in-tree filepath library 9dd7ad2acc Fix dependencies 497184390e Bring mtl dependency back 6c5f5c9bd9 Minor clean up of Hadrian dependencies 9aff81d424 Fix Windows build fa95caa8df Unbreak `cabal new-build` git-subtree-dir: hadrian git-subtree-split: 4499b294e4a53f71f8808d6eb55a7dd0b341cfb8
Diffstat (limited to 'build.nix.sh')
-rwxr-xr-xbuild.nix.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/build.nix.sh b/build.nix.sh
new file mode 100755
index 0000000000..4b03ea8418
--- /dev/null
+++ b/build.nix.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash shell.nix
+
+# This script sets up the build environment by invoking nix-shell shell.nix
+# and then runs the hadrian executable.
+
+function rl {
+ TARGET_FILE="$1"
+
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+
+ # Iterate down a (possible) chain of symlinks
+ while [ -L "$TARGET_FILE" ]
+ do
+ TARGET_FILE="$(readlink "$TARGET_FILE")"
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+ done
+
+ # Compute the canonicalized name by finding the physical path
+ # for the directory we're in and appending the target file.
+ PHYS_DIR="$(pwd -P)"
+ RESULT="$PHYS_DIR/$TARGET_FILE"
+ echo "$RESULT"
+}
+
+absoluteRoot="$(dirname "$(rl "$0")")"
+echo $absoluteRoot
+cd "$absoluteRoot"
+
+hadrian \
+ --lint \
+ --directory="$absoluteRoot/.." \
+ "$@"