chore(edef/users/depot-scan): move to a subdir

Change-Id: If202b466aa0874048e89e0dc270ff14883510131
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1652
Reviewed-by: edef <edef@edef.eu>
Tested-by: BuildkiteCI
This commit is contained in:
edef 2020-08-05 01:52:12 +00:00
parent fcffacf8c9
commit 68ab0a0705
3 changed files with 1 additions and 3 deletions

View file

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

View file

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

View file

@ -0,0 +1,15 @@
# this wraps import to override readFile and readDir to trace the files it touches
# technique inspired by lorri
let
global = {
import = global.scopedImport {};
scopedImport = x: builtins.scopedImport (global // x);
builtins = builtins // {
inherit (global) import scopedImport;
readFile = path: builtins.trace "depot-scan '${toString path}'" (builtins.readFile path);
readDir = path: builtins.trace "depot-scan '${toString path}'" (builtins.readDir path);
};
};
in global.import