publish: Add '--nar-path'.

* guix/scripts/publish.scm (show-help, %options): Add '--nar-path'.
(%default-options): Add 'nar-path'.
(guix-publish): Honor it.
This commit is contained in:
Ludovic Courtès 2017-03-22 14:00:06 +01:00
parent cdd7a7d210
commit 4bb5e0aeb3
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 18 additions and 0 deletions

View File

@ -6523,6 +6523,14 @@ This allows the user's Guix to keep substitute information in cache for
guarantee that the store items it provides will indeed remain available guarantee that the store items it provides will indeed remain available
for as long as @var{ttl}. for as long as @var{ttl}.
@item --nar-path=@var{path}
Use @var{path} as the prefix for the URLs of ``nar'' files
(@pxref{Invoking guix archive, normalized archives}).
By default, nars are served at a URL such as
@code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
change the @code{/nar} part to @var{path}.
@item --public-key=@var{file} @item --public-key=@var{file}
@itemx --private-key=@var{file} @itemx --private-key=@var{file}
Use the specific @var{file}s as the public/private key pair used to sign Use the specific @var{file}s as the public/private key pair used to sign

View File

@ -71,6 +71,8 @@ Publish ~a over HTTP.\n") %store-directory)
compress archives at LEVEL")) compress archives at LEVEL"))
(display (_ " (display (_ "
--ttl=TTL announce narinfos can be cached for TTL seconds")) --ttl=TTL announce narinfos can be cached for TTL seconds"))
(display (_ "
--nar-path=PATH use PATH as the prefix for nar URLs"))
(display (_ " (display (_ "
--public-key=FILE use FILE as the public key for signatures")) --public-key=FILE use FILE as the public key for signatures"))
(display (_ " (display (_ "
@ -152,6 +154,9 @@ compression disabled~%"))
(leave (_ "~a: invalid duration~%") arg)) (leave (_ "~a: invalid duration~%") arg))
(alist-cons 'narinfo-ttl (time-second duration) (alist-cons 'narinfo-ttl (time-second duration)
result)))) result))))
(option '("nar-path") #t #f
(lambda (opt name arg result)
(alist-cons 'nar-path arg result)))
(option '("public-key") #t #f (option '("public-key") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'public-key-file arg result))) (alist-cons 'public-key-file arg result)))
@ -167,6 +172,9 @@ compression disabled~%"))
(define %default-options (define %default-options
`((port . 8080) `((port . 8080)
;; By default, serve nars under "/nar".
(nar-path . "nar")
(public-key-file . ,%public-key-file) (public-key-file . ,%public-key-file)
(private-key-file . ,%private-key-file) (private-key-file . ,%private-key-file)
@ -589,6 +597,7 @@ blocking."
(sockaddr:addr addr) (sockaddr:addr addr)
port))) port)))
(socket (open-server-socket address)) (socket (open-server-socket address))
(nar-path (assoc-ref opts 'nar-path))
(repl-port (assoc-ref opts 'repl)) (repl-port (assoc-ref opts 'repl))
;; Read the key right away so that (1) we fail early on if we can't ;; Read the key right away so that (1) we fail early on if we can't
@ -615,5 +624,6 @@ consider using the '--user' option!~%")))
(repl:spawn-server (repl:make-tcp-server-socket #:port repl-port))) (repl:spawn-server (repl:make-tcp-server-socket #:port repl-port)))
(with-store store (with-store store
(run-publish-server socket store (run-publish-server socket store
#:nar-path nar-path
#:compression compression #:compression compression
#:narinfo-ttl ttl)))))) #:narinfo-ttl ttl))))))