summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-11-03 17:23:10 +0100
committerLudovic Courtès <ludo@gnu.org>2015-11-03 18:11:45 +0100
commit1c52181f33ec6c2b91f1361f7251769dd29c6ef2 (patch)
tree871cf6f9e3eba2ede8939e21b7c0e7c78f2b8a89
parent00bfa7ea25b4612d730b057308b304d0131bee03 (diff)
services: Add 'guix-publish-service'.
* gnu/services/base.scm (<guix-publish-configuration>): New record type. (guix-publish-dmd-service): New procedure. (%guix-publish-accounts, guix-publish-service-type): New variables. (guix-publish-service): New procedure. * doc/guix.texi (Invoking guix publish): Add xref to 'guix-publish-service' anchor. (Base Services): Document 'guix-publish-service'.
-rw-r--r--doc/guix.texi16
-rw-r--r--gnu/services/base.scm61
2 files changed, 77 insertions, 0 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 2ec25b21a1f..996192c0eac 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4918,6 +4918,11 @@ Reference Manual}) on @var{port} (37146 by default). This is used
4918primarily for debugging a running @command{guix publish} server. 4918primarily for debugging a running @command{guix publish} server.
4919@end table 4919@end table
4920 4920
4921Enabling @command{guix publish} on a GuixSD system is a one-liner: just
4922add a call to @code{guix-publish-service} in the @code{services} field
4923of the @code{operating-system} declaration (@pxref{guix-publish-service,
4924@code{guix-publish-service}}).
4925
4921 4926
4922@node Invoking guix challenge 4927@node Invoking guix challenge
4923@section Invoking @command{guix challenge} 4928@section Invoking @command{guix challenge}
@@ -6428,6 +6433,17 @@ Return a service to load console keymap from @var{file} using
6428@command{loadkeys} command. 6433@command{loadkeys} command.
6429@end deffn 6434@end deffn
6430 6435
6436@anchor{guix-publish-service}
6437@deffn {Scheme Procedure} guix-publish-service [#:guix @var{guix}] @
6438 [#:port 80] [#:host "localhost"]
6439Return a service that runs @command{guix publish} listening on @var{host}
6440and @var{port} (@pxref{Invoking guix publish}).
6441
6442This assumes that @file{/etc/guix} already contains a signing key pair as
6443created by @command{guix archive --generate-key} (@pxref{Invoking guix
6444archive}). If that is not the case, the service will fail to start.
6445@end deffn
6446
6431 6447
6432@node Networking Services 6448@node Networking Services
6433@subsubsection Networking Services 6449@subsubsection Networking Services
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 604416b9855..9d495565ad8 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -76,6 +76,10 @@
76 guix-configuration? 76 guix-configuration?
77 guix-service 77 guix-service
78 guix-service-type 78 guix-service-type
79 guix-publish-configuration
80 guix-publish-configuration?
81 guix-publish-service
82 guix-publish-service-type
79 83
80 %base-services)) 84 %base-services))
81 85
@@ -705,6 +709,11 @@ If configuration file name @var{config-file} is not specified, use some
705reasonable default settings." 709reasonable default settings."
706 (service syslog-service-type config-file)) 710 (service syslog-service-type config-file))
707 711
712
713;;;
714;;; Guix services.
715;;;
716
708(define* (guix-build-accounts count #:key 717(define* (guix-build-accounts count #:key
709 (group "guixbuild") 718 (group "guixbuild")
710 (first-uid 30001) 719 (first-uid 30001)
@@ -842,6 +851,58 @@ failed to register hydra.gnu.org public key: ~a~%" status))))))))
842@var{config}." 851@var{config}."
843 (service guix-service-type config)) 852 (service guix-service-type config))
844 853
854
855(define-record-type* <guix-publish-configuration>
856 guix-publish-configuration make-guix-publish-configuration
857 guix-publish-configuration?
858 (guix guix-publish-configuration-guix ;package
859 (default guix))
860 (port guix-publish-configuration-port ;number
861 (default 80))
862 (host guix-publish-configuration-host ;string
863 (default "localhost")))
864
865(define guix-publish-dmd-service
866 (match-lambda
867 (($ <guix-publish-configuration> guix port host)
868 (list (dmd-service
869 (provision '(guix-publish))
870 (requirement '(guix-daemon))
871 (start #~(make-forkexec-constructor
872 (list (string-append #$guix "/bin/guix")
873 "publish" "-u" "guix-publish"
874 "-p" #$(number->string port)
875 (string-append "--listen=" #$host))))
876 (stop #~(make-kill-destructor)))))))
877
878(define %guix-publish-accounts
879 (list (user-group (name "guix-publish") (system? #t))
880 (user-account
881 (name "guix-publish")
882 (group "guix-publish")
883 (system? #t)
884 (comment "guix publish user")
885 (home-directory "/var/empty")
886 (shell #~(string-append #$shadow "/sbin/nologin")))))
887
888(define guix-publish-service-type
889 (service-type (name 'guix-publish)
890 (extensions
891 (list (service-extension dmd-root-service-type
892 guix-publish-dmd-service)
893 (service-extension account-service-type
894 (const %guix-publish-accounts))))))
895
896(define* (guix-publish-service #:key (guix guix) (port 80) (host "localhost"))
897 "Return a service that runs @command{guix publish} listening on @var{host}
898and @var{port} (@pxref{Invoking guix publish}).
899
900This assumes that @file{/etc/guix} already contains a signing key pair as
901created by @command{guix archive --generate-key} (@pxref{Invoking guix
902archive}). If that is not the case, the service will fail to start."
903 (service guix-publish-service-type
904 (guix-publish-configuration (guix guix) (port port) (host host))))
905
845 906
846;;; 907;;;
847;;; Udev. 908;;; Udev.