(zilch nixpkgs): print stderr through (current-error-port)
This fixes the nix-instantiate warning/etc leaking through the CLI.
This commit is contained in:
parent
e86317583d
commit
fa3103ac82
1 changed files with 13 additions and 2 deletions
|
|
@ -2,12 +2,22 @@
|
|||
(import
|
||||
(scheme base)
|
||||
(zilch magic) (zilch nix drv) (zilch nix hash)
|
||||
(srfi 18)
|
||||
(chicken process))
|
||||
(export nix-prefetch-url nixpkgs)
|
||||
|
||||
(begin
|
||||
(define (run-stderr-thread prefix port)
|
||||
(define line (read-line port))
|
||||
(if (eof-object? line)
|
||||
(close-port port)
|
||||
(begin
|
||||
(write-string (string-append prefix "> " line "\n") (current-error-port))
|
||||
(run-stderr-thread prefix port))))
|
||||
|
||||
(define (read-from-nixpkgs path)
|
||||
(define-values (stdout stdin pid) (process "nix-instantiate" `("--argstr" "path" ,path "-E" "{path}: let nixpkgs = import <nixpkgs> {}; in nixpkgs.${path}.out")))
|
||||
(define-values (stdout stdin pid stderr) (process* "nix-instantiate" `("--argstr" "path" ,path "-E" "{path}: let nixpkgs = import <nixpkgs> {}; in nixpkgs.${path}.out")))
|
||||
(define thread (thread-start! (make-thread (lambda () (run-stderr-thread (string-append "nixpkgs." path) stderr)) "read-from-nixpkgs stderr passthrough")))
|
||||
(close-port stdin)
|
||||
(define drvpath (read-line stdout))
|
||||
(define-values (_ _ _) (process-wait pid #t))
|
||||
|
|
@ -16,7 +26,8 @@
|
|||
|
||||
;; Returns the hash (as bytevector) of prefetching the specified URL.
|
||||
(define (nix-prefetch-url name url)
|
||||
(define-values (stdout stdin pid) (process "nix-prefetch-url" `("--name" ,name "--" ,url)))
|
||||
(define-values (stdout stdin pid stderr) (process* "nix-prefetch-url" `("--name" ,name "--" ,url)))
|
||||
(define thread (thread-start! (make-thread (lambda () (run-stderr-thread (string-append "nix-prefetch-url " url) stderr)) "nix-prefetch-url stderr passthrough")))
|
||||
(close-port stdin)
|
||||
(define hash (read-line stdout))
|
||||
(define-values (_ _ _) (process-wait pid #t))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue