diff options
author | sterni <sternenseemann@systemli.org> | 2022-11-10T11·44+0100 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2022-11-20T20·33+0000 |
commit | 982022826da18904092be5e282f538662802228b (patch) | |
tree | b0d841f203a4c44eaf5d063e817af9d4e13a06e8 /tools | |
parent | 3d8849e68bc198efeb8a179a4bcf32771d7967fe (diff) |
fix(tools/magrathea): pass through nix-build exit status r/5292
Something I missed last time reading through the process documentation is that you can use a combination of `process` and `process-wait` to determine the exit status of a child process *and* read from its standard output. With `process*` we could even capture stderr, but we probably want it mounted to the parent process' stderr anyways. Change-Id: I9840f607df465caa80d28109e344e5fc1402949d Reviewed-on: https://cl.tvl.fyi/c/depot/+/7259 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/magrathea/mg.scm | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/magrathea/mg.scm b/tools/magrathea/mg.scm index ab8e5bb77e02..4a2a5ca6ded9 100644 --- a/tools/magrathea/mg.scm +++ b/tools/magrathea/mg.scm @@ -296,19 +296,19 @@ if you meant to pass these arguments to nix, please separate them with (define (execute-run t #!optional cmd-args) (fprintf (current-error-port) "[mg] building target ~A~%" t) (let* ((expr (nix-expr-for t)) - (out (call-with-input-pipe - (apply string-append - ;; TODO(sterni): temporary gc root - (intersperse `("nix-build" "-E" ,(qs expr) "--no-out-link") - " ")) - (lambda (p) - (string-chomp (let ((s (read-string #f p))) - (if (eq? s #!eof) "" s))))))) - - ;; TODO(sterni): can we get the exit code of nix-build somehow? - (when (= (string-length out) 0) - (mg-error (string-append "Couldn't build target " (format "~A" t))) - (exit 1)) + (out + (receive (pipe _ pid) + ;; TODO(sterni): temporary gc root + (process "nix-build" (list "-E" expr "--no-out-link")) + (let ((stdout (string-chomp + (let ((s (read-string #f pipe))) + (if (eq? s #!eof) "" s))))) + (receive (_ _ status) + (process-wait pid) + (when (not (eq? status 0)) + (mg-error (format "Couldn't build target ~A" t)) + (exit status)) + stdout))))) (fprintf (current-error-port) "[mg] running target ~A~%" t) (process-execute |