tvl-depot/users/Profpatsch/lib.nix
Profpatsch 80e1ece329 feat(users/Profpatsch): set up a file watcher for tree sitter
Uses inotify to watch a file and print when it is modified, so we can
update the parser and display the sexp on the terminal.

Now the setup is good enough to start experiementing with queries on
the syntax tree.

Change-Id: I091587fc495ff627c79a69a52915aaaa8c51fcd2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2411
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-17 11:37:39 +00:00

35 lines
773 B
Nix

{ depot, pkgs, ... }:
let
bins = depot.nix.getBins pkgs.coreutils [ "printf" "echo" "cat" "printenv" ]
// depot.nix.getBins pkgs.fdtools [ "multitee" ]
;
debugExec = msg: depot.nix.writeExecline "debug-exec" {} [
"if" [
"fdmove" "-c" "1" "2"
"if" [ bins.printf "%s: " msg ]
"if" [ bins.echo "$@" ]
]
"$@"
];
eprintf = depot.nix.writeExecline "eprintf" {} [
"fdmove" "-c" "1" "2" bins.printf "$@"
];
eprint-stdin = depot.nix.writeExecline "eprint-stdin" {} [
"pipeline" [ bins.multitee "0-1,2" ] "$@"
];
eprintenv = depot.nix.writeExecline "eprintenv" { readNArgs = 1; } [
"fdmove" "-c" "1" "2" bins.printenv "$1"
];
in {
inherit
debugExec
eprintf
eprint-stdin
eprintenv
;
}