(zilch nix daemon): add more daemon calls
This commit is contained in:
parent
7cdf45ef96
commit
f8dd673609
3 changed files with 99 additions and 2 deletions
|
|
@ -17,6 +17,7 @@
|
|||
srfi-151
|
||||
srfi-152
|
||||
srfi-180
|
||||
srfi-207
|
||||
trace
|
||||
json
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
(define-library (zilch nix daemon)
|
||||
(import (scheme base) (scheme write) (scheme case-lambda) (zilch lib hash) srfi-151
|
||||
(zilch nix binproto) socket
|
||||
(srfi 18) (srfi 207)
|
||||
(chicken format))
|
||||
|
||||
(export
|
||||
|
|
@ -19,10 +20,19 @@
|
|||
daemon-wop-handshake daemon-wop-set-options
|
||||
daemon-wop-add-text-to-store daemon-wop-build-paths
|
||||
daemon-wop-query-derivation-output-map
|
||||
daemon-wop-query-path-info
|
||||
daemon-wop-nar-from-path
|
||||
daemon-wop-add-to-store-nar
|
||||
|
||||
<nix-activity> nix-activity?
|
||||
nix-activity-id nix-activity-log-level nix-activity-type
|
||||
nix-activity-string nix-activity-fields nix-activity-parent-id)
|
||||
nix-activity-string nix-activity-fields nix-activity-parent-id
|
||||
|
||||
<valid-path-info> valid-path-info?
|
||||
valid-path-info-deriver valid-path-info-nar-hash valid-path-info-references
|
||||
valid-path-info-registration-time valid-path-info-nar-size valid-path-info-ultimate
|
||||
valid-path-info-sigs valid-path-info-ca)
|
||||
|
||||
|
||||
(begin
|
||||
(define-record-type <daemon-link-settings>
|
||||
|
|
@ -251,6 +261,92 @@
|
|||
(daemon-read-log-events link)
|
||||
(daemon-read-string link))
|
||||
|
||||
(define-record-type <valid-path-info>
|
||||
(make-valid-path-info deriver nar-hash references registration-time nar-size ultimate sigs ca)
|
||||
valid-path-info?
|
||||
(deriver valid-path-info-deriver)
|
||||
(nar-hash valid-path-info-nar-hash)
|
||||
(references valid-path-info-references)
|
||||
(registration-time valid-path-info-registration-time)
|
||||
(nar-size valid-path-info-nar-size)
|
||||
(ultimate valid-path-info-ultimate)
|
||||
(sigs valid-path-info-sigs)
|
||||
(ca valid-path-info-ca))
|
||||
|
||||
(define (read-string-list link)
|
||||
(define count (daemon-read-u64 link))
|
||||
(do ((out '()) (i 0 (+ i 1)))
|
||||
((>= i count) (reverse out))
|
||||
(set! out (cons (daemon-read-string link) out))))
|
||||
|
||||
(define (daemon-read-valid-path-info link)
|
||||
(define deriver (daemon-read-string link))
|
||||
(define nar-hash (daemon-read-string link))
|
||||
(define references (read-string-list link))
|
||||
(define registration-time (daemon-read-u64 link))
|
||||
(define nar-size (daemon-read-u64 link))
|
||||
(define ultimate (daemon-read-u64 link))
|
||||
(define sigs (read-string-list link))
|
||||
(define ca (daemon-read-string link))
|
||||
|
||||
(make-valid-path-info
|
||||
(if (string=? deriver "") #f deriver)
|
||||
(hex-string->bytevector nar-hash)
|
||||
references registration-time nar-size (= ultimate 1) sigs
|
||||
(if (string=? ca "") #f ca)))
|
||||
|
||||
(define (daemon-wop-query-path-info link store-path)
|
||||
(daemon-write-u64 link 26)
|
||||
(daemon-write-string link store-path)
|
||||
(daemon-flush link)
|
||||
(daemon-read-log-events link)
|
||||
(define ok (daemon-read-u64 link))
|
||||
(if (= ok 1)
|
||||
(daemon-read-valid-path-info link)
|
||||
#f))
|
||||
|
||||
; You are responsible for reading exactly the right amount of bytes from
|
||||
; the daemon after this. My condolences.
|
||||
(define (daemon-wop-nar-from-path link store-path)
|
||||
(daemon-write-u64 link 38)
|
||||
(daemon-write-string link store-path)
|
||||
(daemon-flush link)
|
||||
(daemon-read-log-events link))
|
||||
|
||||
; `proc` is a procedure taking one argument, which is used to write data into the daemon.
|
||||
; The write-blob procedure passed to `proc` looks like (write-blob bv [start [end]]).
|
||||
(define (daemon-wop-add-to-store-nar link store-path deriver nar-hash references nar-size ca proc)
|
||||
(daemon-write-u64 link 39)
|
||||
(daemon-write-string link store-path)
|
||||
(daemon-write-string link (or deriver ""))
|
||||
(daemon-write-string link nar-hash)
|
||||
(daemon-write-u64 link (length references))
|
||||
(for-each (lambda (v) (daemon-write-string link v)) references)
|
||||
(daemon-write-u64 link 0) ; registration time
|
||||
(daemon-write-u64 link nar-size) ; registration time
|
||||
(daemon-write-u64 link 1) ; ultimate
|
||||
(daemon-write-u64 link 0) ; sigs
|
||||
(daemon-write-string link ca)
|
||||
(daemon-write-u64 link 0) ; repair
|
||||
(daemon-write-u64 link 0) ; dontCheckSigs
|
||||
|
||||
(daemon-flush link)
|
||||
(define write-blob
|
||||
(case-lambda
|
||||
((bv) (daemon-write-u64 link (bytevector-length bv)) (write-bytevector bv (daemon-link-out-port link)))
|
||||
((bv start) (daemon-write-u64 link (- (bytevector-length bv) start)) (write-bytevector bv (daemon-link-out-port link) start))
|
||||
((bv start end) (daemon-write-u64 link (- end start)) (write-bytevector bv (daemon-link-out-port link) start end))))
|
||||
|
||||
(define data-thread
|
||||
(make-thread
|
||||
(lambda ()
|
||||
(proc write-blob)
|
||||
(daemon-write-u64 link 0) ; send an EOF
|
||||
(daemon-flush link))))
|
||||
(thread-start! data-thread)
|
||||
(daemon-read-log-events link)
|
||||
(thread-join! data-thread))
|
||||
|
||||
(define (daemon-wop-query-derivation-output-map link store-path)
|
||||
(daemon-write-u64 link 41)
|
||||
(daemon-write-string link store-path)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
((version "0.0.1")
|
||||
(synopsis "Nix. Noppes. Nada.")
|
||||
(author "puck")
|
||||
(dependencies socket r7rs vector-lib srfi-60 srfi-113 srfi-128 srfi-132 srfi-146 srfi-151 srfi-152 srfi-180 trace json)
|
||||
(dependencies socket r7rs vector-lib srfi-60 srfi-113 srfi-128 srfi-132 srfi-146 srfi-151 srfi-152 srfi-180 srfi-207 trace json)
|
||||
(component-options
|
||||
(csc-options "-X" "r7rs" "-R" "r7rs" "-optimize-level" "3"))
|
||||
(components
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue