From 29bab159ab780ada20a4ae97956594ea13b38ab4 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 15 Jun 2020 20:03:47 +0100 Subject: 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 --- bin/__dispatch.sh | 3 +++ bin/depot-build | 1 + tools/depot-build.nix | 8 ++++++++ 3 files changed, 12 insertions(+) create mode 120000 bin/depot-build create mode 100644 tools/depot-build.nix diff --git a/bin/__dispatch.sh b/bin/__dispatch.sh index 0808e1f634..d8214bccd0 100755 --- a/bin/__dispatch.sh +++ b/bin/__dispatch.sh @@ -47,6 +47,9 @@ case "${TARGET_TOOL}" in 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." exit 1 diff --git a/bin/depot-build b/bin/depot-build new file mode 120000 index 0000000000..8390ec9c96 --- /dev/null +++ b/bin/depot-build @@ -0,0 +1 @@ +__dispatch.sh \ No newline at end of file diff --git a/tools/depot-build.nix b/tools/depot-build.nix new file mode 100644 index 0000000000..5661d58760 --- /dev/null +++ b/tools/depot-build.nix @@ -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) +'' -- cgit 1.4.1