feat(tools/magrathea): add repl command

`mg repl` is essentially a shortcut for nix repl $(mg path //) which
comes up often enough for me. Launching a repl only really makes sense
in the repository root with how readTree works at the moment, so I think
this is a convenient addition.

Change-Id: I32b695885c2e6eaecdcc656c7249afa504439913
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5822
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
sterni 2022-06-01 12:27:59 +02:00 committed by clbot
parent ae422c1353
commit 89f3f0a5dc

View file

@ -39,6 +39,7 @@ commands:
build - build a target
shell - enter a shell with the target's build dependencies
path - print source folder for the target
repl - start a nix repl in the repository root
run - build a target and execute its output
file all feedback on b.tvl.fyi
@ -289,6 +290,9 @@ if you meant to pass these arguments to nix, please separate them with
(guarantee-success (parse-target arg)))]
[other (print "not yet implemented")]))
(define (repl args)
(process-execute "nix" (append (list "repl" "--show-trace" (repository-root)) args)))
(define (execute-run t #!optional cmd-args)
(fprintf (current-error-port) "[mg] building target ~A~%" t)
(let* ((expr (nix-expr-for t))
@ -352,6 +356,7 @@ if you meant to pass these arguments to nix, please separate them with
[("build" . _) (build (cdr args))]
[("shell" . _) (shell (cdr args))]
[("path" . _) (path (cdr args))]
[("repl" . _) (repl (cdr args))]
[("run" . _) (run (cdr args))]
[other (begin (print "unknown command: mg " args)
(print usage))]))