feat(depot-build): Add a tool to build at arbitrary tree locations

Assuming you're in `/depot/fun/clbot`, you can do this:

    tazjin@frog /d/f/clbot (master)> depot-build
    Building //fun/clbot
    /nix/store/i1zc6g58wa4819kyhaqi12zsh3hr31ph-clbot

It is automatically added to the $PATH using direnv, too.

Change-Id: Ia3341704e6317c2b8de40a3fa1be3b680d21a42d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/388
Reviewed-by: eta <eta@theta.eu.org>
This commit is contained in:
Vincent Ambo 2020-06-15 20:03:47 +01:00 committed by tazjin
parent c26ee5a448
commit 29bab159ab
3 changed files with 12 additions and 0 deletions

View file

@ -47,6 +47,9 @@ case "${TARGET_TOOL}" in
git-bug) git-bug)
attr="third_party.git-bug" attr="third_party.git-bug"
;; ;;
depot-build)
attr="tools.depot-build"
;;
*) *)
echo "The tool '${TARGET_TOOL}' is currently not installed in this repository." echo "The tool '${TARGET_TOOL}' is currently not installed in this repository."
exit 1 exit 1

1
bin/depot-build Symbolic link
View file

@ -0,0 +1 @@
__dispatch.sh

8
tools/depot-build.nix Normal file
View file

@ -0,0 +1,8 @@
# Utility script for building any arbitrary depot path in its folder.
{ pkgs, ... }:
pkgs.writeShellScriptBin "depot-build" ''
TARGET=$(git rev-parse --show-prefix | sed 's|/$||')
echo "Building //$TARGET"
nix-build -A $(echo $TARGET | sed 's|/|.|') $(${pkgs.git}/bin/git rev-parse --show-toplevel)
''