about summary refs log tree commit diff
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2020-08-05T00·31+0000
committeredef <edef@edef.eu>2020-08-05T00·46+0000
commit48e47d9280bad0ed6cbd727df9706f4822583358 (patch)
tree629710ab3d4db940a9437a2cecbde37d137c2d60
parent58e3608e258d35e1a8b132cd65a20d2200f01b9f (diff)
feat(edef/depot-scan): init r/1587
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
-rw-r--r--users/edef/depot-scan.nix12
-rwxr-xr-xusers/edef/sources.pl11
2 files changed, 23 insertions, 0 deletions
diff --git a/users/edef/depot-scan.nix b/users/edef/depot-scan.nix
new file mode 100644
index 000000000000..faa91855e8f9
--- /dev/null
+++ b/users/edef/depot-scan.nix
@@ -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
+''
diff --git a/users/edef/sources.pl b/users/edef/sources.pl
new file mode 100755
index 000000000000..39550d83c1a5
--- /dev/null
+++ b/users/edef/sources.pl
@@ -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 '.*' -> '.*'$/;