From a9650041bb73366d9be73bcbe34faf8694f9aa2c Mon Sep 17 00:00:00 2001 From: Kane York Date: Thu, 20 Aug 2020 18:15:33 -0700 Subject: feat(tools/tvlc): pass list of derivations to depot-scanner You can now provide a list of Nix derivations to tvlc to get a git worktree + sparse-checkout containing only the paths needed to build the specified derivations. Known bugs: even though //third_party is only passed to readdir(), git doesn't know this and includes all of //third_party/*. Change-Id: I9dccebd3fbff4bb04ebd568175cf0a7e37d71ab3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1826 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tools/tvlc/tvlc-new | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools/tvlc/tvlc-new') diff --git a/tools/tvlc/tvlc-new b/tools/tvlc/tvlc-new index e3e65b4f64..4ef0df5d33 100755 --- a/tools/tvlc/tvlc-new +++ b/tools/tvlc/tvlc-new @@ -79,7 +79,8 @@ if [ -f "$DEPOT_ROOT/.git/refs/heads/$branch_name" ]; then exit 1 fi -# TODO(riking): tvlc-get-depends +# The big one: call into Nix to figure out what paths the desired derivations depend on. +readarray -t includedPaths < <("$depot_scanner" --mode 'print' --only 'DEPOT' --relpath --depot "$DEPOT_ROOT" --nix-bin "$tvix_instantiate" "$@") # bash math checkout_id=$(("$(cat "$tvlc_root/next_clientid")")) @@ -95,7 +96,7 @@ mkdir "$DEPOT_ROOT/.git/worktrees/$checkout_id/info" cd "$checkout_dir" git sparse-checkout init --cone -git sparse-checkout set "$@" +git sparse-checkout set "${includedPaths[@]}" ln -s "$checkout_dir" "$nice_checkout_root"/"$checkout_name" -- cgit 1.4.1