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
|
|
|
|
|
2020-07-01 22:39:25 +02:00
|
|
|
readonly REPO_ROOT=$(dirname "$0")/..
|
|
|
|
TARGET_TOOL=$(basename "$0")
|
2019-07-02 17:40:51 +02:00
|
|
|
|
|
|
|
case "${TARGET_TOOL}" in
|
2020-01-01 16:54:07 +01:00
|
|
|
age)
|
2021-09-15 01:11:40 +02:00
|
|
|
attr="third_party.nixpkgs-age"
|
2020-01-01 16:54:07 +01:00
|
|
|
;;
|
|
|
|
age-keygen)
|
2021-09-15 01:11:40 +02:00
|
|
|
attr="third_party.nixpkgs.age"
|
2020-01-01 16:54:07 +01:00
|
|
|
;;
|
2020-07-15 15:51:59 +02:00
|
|
|
depot-build)
|
|
|
|
attr="tools.depot-build"
|
2020-05-17 03:49:13 +02:00
|
|
|
;;
|
2021-07-16 21:07:31 +02:00
|
|
|
depot-nixpkgs-update)
|
|
|
|
attr="tools.depot-nixpkgs-update"
|
|
|
|
;;
|
2020-06-16 02:54:26 +02:00
|
|
|
gerrit)
|
|
|
|
attr="tools.gerrit-cli"
|
|
|
|
;;
|
2020-11-29 04:34:26 +01:00
|
|
|
gerrit-update)
|
|
|
|
attr="tools.gerrit-update"
|
|
|
|
;;
|
2020-07-01 22:29:35 +02:00
|
|
|
hash-password)
|
|
|
|
attr="tools.hash-password"
|
|
|
|
;;
|
2020-07-15 15:51:59 +02:00
|
|
|
kontemplate)
|
2021-09-15 01:11:40 +02:00
|
|
|
attr="ops.kontemplate"
|
2020-07-15 15:51:59 +02:00
|
|
|
;;
|
|
|
|
meson)
|
2021-09-15 01:11:40 +02:00
|
|
|
attr="third_party.nixpkgs.meson"
|
2020-07-15 15:51:59 +02:00
|
|
|
;;
|
2021-12-15 17:31:47 +01:00
|
|
|
mg)
|
|
|
|
attr="tools.magrathea"
|
|
|
|
;;
|
2020-07-15 15:51:59 +02:00
|
|
|
ninja)
|
2021-09-15 01:11:40 +02:00
|
|
|
attr="third_party.nixpkgs.ninja"
|
2020-07-15 15:51:59 +02:00
|
|
|
;;
|
2021-09-15 01:09:13 +02:00
|
|
|
nint)
|
|
|
|
attr="nix.nint"
|
|
|
|
;;
|
2020-07-15 15:54:18 +02:00
|
|
|
perf-flamegraph)
|
|
|
|
attr="tools.perf-flamegraph"
|
|
|
|
;;
|
2020-07-03 06:26:33 +02:00
|
|
|
rebuild-system)
|
|
|
|
attr="ops.nixos.rebuild-system"
|
|
|
|
;;
|
2020-07-15 15:51:59 +02:00
|
|
|
rink)
|
2021-09-15 01:11:40 +02:00
|
|
|
attr="third_party.nixpkgs.rink"
|
2020-07-15 15:51:59 +02:00
|
|
|
;;
|
|
|
|
stern)
|
2021-09-15 01:11:40 +02:00
|
|
|
attr="third_party.nixpkgs.stern"
|
2020-07-15 15:51:59 +02:00
|
|
|
;;
|
2021-12-18 14:01:10 +01:00
|
|
|
depotfmt)
|
|
|
|
attr="tools.depotfmt"
|
|
|
|
;;
|
2021-12-24 17:23:08 +01:00
|
|
|
tf-glesys)
|
|
|
|
TARGET_TOOL="terraform"
|
|
|
|
attr="ops.glesys.terraform"
|
|
|
|
;;
|
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}" "${@}"
|