feat(edef/depot-scan): init

A small script that parses `nix-instantiate -vv` output to track the
files read while instantiating a depot build.

Change-Id: I5acf31d55f39c1d1acf9cdead03d33e2c8abab6a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1646
Reviewed-by: edef <edef@edef.eu>
Tested-by: BuildkiteCI
This commit is contained in:
edef 2020-08-05 00:31:18 +00:00
parent 58e3608e25
commit 48e47d9280
2 changed files with 23 additions and 0 deletions

12
users/edef/depot-scan.nix Normal file
View file

@ -0,0 +1,12 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "depot-scan" ''
set -euo pipefail
path=$(git rev-parse --show-prefix)
path="''${path%%/}"
attr="''${path//\//.}"
root="$(git rev-parse --show-toplevel)"
echo "scanning //$path" >&2
nix-instantiate "$root" -A "$attr" -vv 2> >(${pkgs.perl}/bin/perl sources.pl) >&2
''

11
users/edef/sources.pl Executable file
View file

@ -0,0 +1,11 @@
#! /usr/bin/env -S perl -ln
use strict;
if (/^evaluating file '(.*)'$/ or
/^copied source '(.*)' -> '.*'$/ or
/^trace: lorri read: '(.*)'$/) {
print $1;
next;
}
print STDERR unless /^instantiated '.*' -> '.*'$/;