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:
parent
fcffacf8c9
commit
68ab0a0705
3 changed files with 1 additions and 3 deletions
12
users/edef/depot-scan/default.nix
Normal file
12
users/edef/depot-scan/default.nix
Normal 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
|
||||
''
|
||||
11
users/edef/depot-scan/depot-scan.pl
Executable file
11
users/edef/depot-scan/depot-scan.pl
Executable 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 '.*' -> '.*'$/;
|
||||
15
users/edef/depot-scan/wrap.nix
Normal file
15
users/edef/depot-scan/wrap.nix
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue