2019-07-02 17:40:51 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# This script dispatches invocations transparently to programs instantiated from
|
|
|
|
# Nix.
|
|
|
|
#
|
2019-07-04 12:15:15 +02:00
|
|
|
# To add a new tool, insert it into the case statement below by setting `attr`
|
|
|
|
# to the key in nixpkgs which represents the program you want to run.
|
2019-07-02 17:40:51 +02:00
|
|
|
set -ueo pipefail
|
|
|
|
|
|
|
|
readonly REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
|
|
readonly TARGET_TOOL=$(basename $0)
|
|
|
|
|
|
|
|
case "${TARGET_TOOL}" in
|
2019-08-15 17:28:42 +02:00
|
|
|
terraform)
|
2019-11-15 16:26:08 +01:00
|
|
|
attr="third_party.terraform-gcp"
|
2019-08-15 17:28:42 +02:00
|
|
|
;;
|
2019-08-16 17:50:50 +02:00
|
|
|
kontemplate)
|
|
|
|
attr="kontemplate"
|
|
|
|
;;
|
2019-08-19 17:58:19 +02:00
|
|
|
blog_cli)
|
2019-11-15 16:26:08 +01:00
|
|
|
attr="tools.blog_cli"
|
2019-08-19 17:58:19 +02:00
|
|
|
;;
|
2019-09-02 19:18:28 +02:00
|
|
|
stern)
|
|
|
|
attr="stern"
|
|
|
|
;;
|
2019-09-03 16:56:31 +02:00
|
|
|
pass)
|
2019-11-15 16:26:08 +01:00
|
|
|
attr="tools.kms_pass"
|
2019-09-03 16:56:31 +02:00
|
|
|
;;
|
2019-12-09 13:27:07 +01:00
|
|
|
aoc2019)
|
|
|
|
attr="tools.aoc2019.${1}"
|
|
|
|
;;
|
2019-07-02 17:40:51 +02:00
|
|
|
*)
|
|
|
|
echo "The tool '${TARGET_TOOL}' is currently not installed in this repository."
|
2019-07-04 12:15:15 +02:00
|
|
|
exit 1
|
2019-07-02 17:40:51 +02:00
|
|
|
;;
|
|
|
|
esac
|
2019-07-04 12:15:15 +02:00
|
|
|
|
|
|
|
result=$(nix-build --no-out-link --attr "${attr}" "${REPO_ROOT}")
|
|
|
|
PATH="${result}/bin:$PATH"
|
|
|
|
|
|
|
|
exec "${TARGET_TOOL}" "${@}"
|