summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.envrc4
-rwxr-xr-xtools/bin/__dispatch.sh31
l---------tools/bin/git-appraise1
3 files changed, 36 insertions, 0 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 000000000000..76e30237cbaf
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,4 @@
+# Configure the local PATH to contain tools which are fetched ad-hoc
+# from Nix.
+
+export PATH="${PWD}/tools/bin:${PATH}"
diff --git a/tools/bin/__dispatch.sh b/tools/bin/__dispatch.sh
new file mode 100755
index 000000000000..7db75bf870f3
--- /dev/null
+++ b/tools/bin/__dispatch.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+# This script dispatches invocations transparently to programs instantiated from
+# Nix.
+#
+# To add a new tool, in
+set -ueo pipefail
+
+readonly REPO_ROOT=$(git rev-parse --show-toplevel)
+readonly ARGS="$@"
+readonly TARGET_TOOL=$(basename $0)
+
+function nix_dispatch() {
+  local attr="${1}"
+  local result=$(nix-build --no-out-link --attr "${attr}" "${REPO_ROOT}")
+
+  PATH="${result}/bin:$PATH"
+  if [ -z "${ARGS}" ]; then
+    exec "${TARGET_TOOL}"
+  else
+    exec "${TARGET_TOOL}" "${ARGS}"
+  fi
+}
+
+case "${TARGET_TOOL}" in
+  git-appraise)
+    nix_dispatch "thirdParty.gitAppraise"
+    ;;
+  *)
+    echo "The tool '${TARGET_TOOL}' is currently not installed in this repository."
+    ;;
+esac
diff --git a/tools/bin/git-appraise b/tools/bin/git-appraise
new file mode 120000
index 000000000000..8390ec9c9652
--- /dev/null
+++ b/tools/bin/git-appraise
@@ -0,0 +1 @@
+__dispatch.sh
\ No newline at end of file