__dispatch.sh (723B)
1 #!/usr/bin/env bash 2 # This script dispatches invocations transparently to programs instantiated from 3 # Nix. 4 # 5 # To add a new tool, insert it into the case statement below by setting `attr` 6 # to the key in nixpkgs which represents the program you want to run. 7 set -ueo pipefail 8 9 readonly REPO_ROOT=$(dirname "$0")/.. 10 TARGET_TOOL=$(basename "$0") 11 12 case "${TARGET_TOOL}" in 13 bus) 14 attr="tools.bus" 15 ;; 16 k8s.infra) 17 attr="tools.k8s_infra" 18 ;; 19 *) 20 echo "The tool '${TARGET_TOOL}' is currently not installed in this repository." 21 exit 1 22 ;; 23 esac 24 25 result=$(nix-build --no-out-link --attr "${attr}" "${REPO_ROOT}") 26 PATH="${result}/bin:$PATH" 27 28 exec "${TARGET_TOOL}" "${@}"