diff options
author | Ludovic Courtès <ludovic.courtes@inria.fr> | 2017-04-21 11:39:49 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-04-21 17:23:37 +0200 |
commit | 1397b422e254929de1805aaf1d0759cd5da6a60b (patch) | |
tree | ca37bb9b955a3f11b10c07905c35b078e0e3f641 /guix/store.scm | |
parent | 031e6087c4c30b00f31824d269cfbf67a7c54f31 (diff) | |
download | gnu-guix-1397b422e254929de1805aaf1d0759cd5da6a60b.tar gnu-guix-1397b422e254929de1805aaf1d0759cd5da6a60b.tar.gz |
store: 'GUIX_DAEMON_SOCKET' can now be a URI.
* guix/store.scm (%daemon-socket-file): Rename to...
(%daemon-socket-uri): ... this.
(connect-to-daemon): New procedure.
(open-connection): Rename 'file' to 'uri'. Use 'connect-to-daemon'
instead of 'open-unix-domain-socket'.
* guix/tests.scm (open-connection-for-tests): Rename 'file' to 'uri'.
* tests/guix-build.sh: Add tests.
* tests/store.scm ("open-connection with file:// URI"): New tests.
Diffstat (limited to 'guix/store.scm')
-rw-r--r-- | guix/store.scm | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/guix/store.scm b/guix/store.scm index 2f05351767..bd07976c37 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -39,7 +39,8 @@ #:use-module (ice-9 regex) #:use-module (ice-9 vlist) #:use-module (ice-9 popen) - #:export (%daemon-socket-file + #:use-module (web uri) + #:export (%daemon-socket-uri %gc-roots-directory %default-substitute-urls @@ -216,8 +217,8 @@ (define %default-socket-path (string-append %state-directory "/daemon-socket/socket")) -(define %daemon-socket-file - ;; File name of the socket the daemon listens too. +(define %daemon-socket-uri + ;; URI or file name of the socket the daemon listens too. (make-parameter (or (getenv "GUIX_DAEMON_SOCKET") %default-socket-path))) @@ -369,10 +370,29 @@ (file file) (errno errno))))))))) -(define* (open-connection #:optional (file (%daemon-socket-file)) +(define (connect-to-daemon uri) + "Connect to the daemon at URI, a string that may be an actual URI or a file +name." + (define connect + (match (string->uri uri) + (#f ;URI is a file name + open-unix-domain-socket) + ((? uri? uri) + (match (uri-scheme uri) + ((or #f 'file 'unix) + (lambda (_) + (open-unix-domain-socket (uri-path uri)))) + (x + (raise (condition (&nix-connection-error + (file (uri->string uri)) + (errno ENOTSUP))))))))) + + (connect uri)) + +(define* (open-connection #:optional (uri (%daemon-socket-uri)) #:key port (reserve-space? #t) cpu-affinity) - "Connect to the daemon over the Unix-domain socket at FILE, or, if PORT is -not #f, use it as the I/O port over which to communicate to a build daemon. + "Connect to the daemon at URI (a string), or, if PORT is not #f, use it as +the I/O port over which to communicate to a build daemon. When RESERVE-SPACE? is true, instruct it to reserve a little bit of extra space on the file system so that the garbage collector can still operate, @@ -383,10 +403,10 @@ for this connection will be pinned. Return a server object." ;; One of the 'write-' or 'read-' calls below failed, but this is ;; really a connection error. (raise (condition - (&nix-connection-error (file (or port file)) + (&nix-connection-error (file (or port uri)) (errno EPROTO)) (&message (message "build daemon handshake failed")))))) - (let ((port (or port (open-unix-domain-socket file)))) + (let ((port (or port (connect-to-daemon uri)))) (write-int %worker-magic-1 port) (let ((r (read-int port))) (and (eqv? r %worker-magic-2) |