summaryrefslogtreecommitdiff
path: root/hadrian/build.stack.nix.sh
diff options
context:
space:
mode:
Diffstat (limited to 'hadrian/build.stack.nix.sh')
-rwxr-xr-xhadrian/build.stack.nix.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/hadrian/build.stack.nix.sh b/hadrian/build.stack.nix.sh
new file mode 100755
index 0000000000..59ac061805
--- /dev/null
+++ b/hadrian/build.stack.nix.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# readlink on os x, doesn't support -f, to prevent the
+# need of installing coreutils (e.g. through brew, just
+# for readlink, we use the follownig substitute.
+#
+# source: http://stackoverflow.com/a/1116890
+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")")"
+
+HADRIAN_NIX=YES ${absoluteRoot}/build.stack.sh