From 375cc7dea20da7117c9459e4a4d15144095e015b Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sun, 22 Nov 2020 15:12:17 +0100 Subject: Add Avahi support. * guix/avahi.scm: New file. * Makefile.am (MODULES): Add it. * configure.ac: Add Guile-Avahi dependency. * doc/guix.texi (Requirements): Document it. * gnu/packages/package-management.scm (guix)[native-inputs]: Add "guile-avahi", [propagated-inputs]: ditto. * guix/self.scm (specification->package): Add guile-avahi. (compiled-guix): Ditto. --- doc/guix.texi | 1 + 1 file changed, 1 insertion(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 07da51f131..baf6e69039 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -829,6 +829,7 @@ Guile,, gnutls-guile, GnuTLS-Guile}); or later; @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib}; @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib}; +@item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi}; @item @c FIXME: Specify a version number once a release has been made. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.3.0 -- cgit v1.2.3 From 276e494b2a1fd87874d80e2bdc3aa1fb833b76f2 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sun, 22 Nov 2020 15:15:17 +0100 Subject: publish: Add advertising support. * guix/scripts/publish.scm (%options): Add "--advertise" option. (show-help): Document it. (service-name): New procedure, (publish-service-type): new variable. (run-publish-server): Add "advertise?" and "port" parameters. Use them to publish the server using Avahi. (guix-publish): Pass the "advertise?" option to "run-publish-server". * gnu/services/base.scm (): Add "advertise?" field. (guix-publish-shepherd-service): Honor it. --- doc/guix.texi | 5 +++++ gnu/services/base.scm | 8 +++++++- guix/scripts/publish.scm | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index baf6e69039..8ca243004a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12159,6 +12159,11 @@ The signing key pair must be generated before @command{guix publish} is launched, using @command{guix archive --generate-key} (@pxref{Invoking guix archive}). +When the @option{--advertise} option is passed, the server advertises +its availability on the local network using multicast DNS (mDNS) and DNS +service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,, +guile-avahi, Using Avahi in Guile Scheme Programs}). + The general syntax is: @example diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 3fc4d5f885..e3b347293e 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1744,6 +1744,8 @@ proxy of 'guix-daemon'...~%") (default 80)) (host guix-publish-configuration-host ;string (default "localhost")) + (advertise? guix-publish-advertise? ;boolean + (default #f)) (compression guix-publish-configuration-compression (thunked) (default (default-compression this-record @@ -1790,7 +1792,8 @@ raise a deprecation warning if the 'compression-level' field was used." lst)))) (match-record config - (guix port host nar-path cache workers ttl cache-bypass-threshold) + (guix port host nar-path cache workers ttl cache-bypass-threshold + advertise?) (list (shepherd-service (provision '(guix-publish)) (requirement '(guix-daemon)) @@ -1801,6 +1804,9 @@ raise a deprecation warning if the 'compression-level' field was used." #$@(config->compression-options config) (string-append "--nar-path=" #$nar-path) (string-append "--listen=" #$host) + #$@(if advertise? + #~("--advertise") + #~()) #$@(if workers #~((string-append "--workers=" #$(number->string diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 2a2185e2b9..4822ea55c0 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -42,6 +42,7 @@ #:use-module (web server) #:use-module (web uri) #:autoload (sxml simple) (sxml->xml) + #:use-module (guix avahi) #:use-module (guix base32) #:use-module (guix base64) #:use-module (guix config) @@ -70,6 +71,7 @@ signed-string open-server-socket + publish-service-type run-publish-server guix-publish)) @@ -83,6 +85,8 @@ Publish ~a over HTTP.\n") %store-directory) (display (G_ " -u, --user=USER change privileges to USER as soon as possible")) (display (G_ " + -a, --advertise advertise on the local network")) + (display (G_ " -C, --compression[=METHOD:LEVEL] compress archives with METHOD at LEVEL")) (display (G_ " @@ -157,6 +161,9 @@ usage." (option '(#\V "version") #f #f (lambda _ (show-version-and-exit "guix publish"))) + (option '(#\a "advertise") #f #f + (lambda (opt name arg result) + (alist-cons 'advertise? #t result))) (option '(#\u "user") #t #f (lambda (opt name arg result) (alist-cons 'user arg result))) @@ -1069,11 +1076,29 @@ methods, return the applicable compression." (x (not-found request))) (not-found request)))) +(define (service-name) + "Return the Avahi service name of the server." + (string-append "guix-publish-" (gethostname))) + +(define publish-service-type + ;; Return the Avahi service type of the server. + "_guix_publish._tcp") + (define* (run-publish-server socket store #:key + advertise? port (compressions (list %no-compression)) (nar-path "nar") narinfo-ttl cache pool) + (when advertise? + (let ((name (service-name))) + ;; XXX: Use a callback from Guile-Avahi here, as Avahi can pick a + ;; different name to avoid name clashes. + (info (G_ "Advertising ~a~%.") name) + (avahi-publish-service-thread name + #:type publish-service-type + #:port port))) + (run-server (make-request-handler store #:cache cache #:pool pool @@ -1119,9 +1144,10 @@ methods, return the applicable compression." (lambda (arg result) (leave (G_ "~A: extraneous argument~%") arg)) %default-options)) - (user (assoc-ref opts 'user)) - (port (assoc-ref opts 'port)) - (ttl (assoc-ref opts 'narinfo-ttl)) + (advertise? (assoc-ref opts 'advertise?)) + (user (assoc-ref opts 'user)) + (port (assoc-ref opts 'port)) + (ttl (assoc-ref opts 'narinfo-ttl)) (compressions (match (filter-map (match-lambda (('compression . compression) compression) @@ -1179,6 +1205,8 @@ consider using the '--user' option!~%"))) (with-store store (run-publish-server socket store + #:advertise? advertise? + #:port port #:cache cache #:pool (and cache (make-pool workers #:thread-name -- cgit v1.2.3 From 79f9dee3c4c0e6d21066f142116a537207ae7ba4 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 24 Nov 2020 14:05:21 +0100 Subject: Use substitute servers on the local network. * guix/scripts/discover.scm: New file. * Makefile.am (MODULES): Add it. * nix/nix-daemon/guix-daemon.cc (options): Add "discover" option, (parse-opt): parse it, (main): start "guix discover" process when the option is set. * guix/scripts/substitute.scm (%local-substitute-urls): New variable, (substitute-urls): add it. * gnu/services/base.scm (): Add "discover?" field, (guix-shepherd-service): honor it. * doc/guix.texi (Invoking guix-daemon): Document "discover" option, (Base Services): ditto. --- Makefile.am | 1 + doc/guix.texi | 26 +++++++ gnu/services/base.scm | 9 ++- guix/scripts/discover.scm | 158 ++++++++++++++++++++++++++++++++++++++++++ guix/scripts/substitute.scm | 32 ++++++++- nix/nix-daemon/guix-daemon.cc | 21 ++++++ 6 files changed, 244 insertions(+), 3 deletions(-) create mode 100644 guix/scripts/discover.scm (limited to 'doc') diff --git a/Makefile.am b/Makefile.am index 7049da9594..41b366eb75 100644 --- a/Makefile.am +++ b/Makefile.am @@ -257,6 +257,7 @@ MODULES = \ guix/import/texlive.scm \ guix/import/utils.scm \ guix/scripts.scm \ + guix/scripts/discover.scm \ guix/scripts/download.scm \ guix/scripts/perform-download.scm \ guix/scripts/build.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 8ca243004a..da6caaa4f1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1579,6 +1579,28 @@ Unless @option{--lose-logs} is used, all the build logs are kept in the @var{localstatedir}. To save space, the daemon automatically compresses them with Bzip2 by default. +@item --discover[=yes|no] +Whether to discover substitute servers on the local network using mDNS +and DNS-SD. + +This feature is still experimental. However, here are a few +considerations. + +@enumerate +@item +It might be faster/less expensive than fetching from remote servers; +@item +There are no security risks, only genuine substitutes will be used +(@pxref{Substitute Authentication}); +@item +An attacker advertising @command{guix publish} on your LAN cannot serve +you malicious binaries, but they can learn what software you’re +installing; +@item +Servers may serve substitute over HTTP, unencrypted, so anyone on the +LAN can see what software you’re installing. +@end enumerate + @item --disable-deduplication @cindex deduplication Disable automatic file ``deduplication'' in the store. @@ -15016,6 +15038,10 @@ disables the timeout. The type of compression used for build logs---one of @code{gzip}, @code{bzip2}, or @code{none}. +@item @code{discover} (default: @code{#f}) +Whether to discover substitute servers on the local network using mDNS +and DNS-SD. + @item @code{extra-options} (default: @code{'()}) List of extra command-line options for @command{guix-daemon}. diff --git a/gnu/services/base.scm b/gnu/services/base.scm index e3b347293e..d0d88e18a6 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1530,6 +1530,8 @@ archive' public keys, with GUIX." (default 0)) (log-compression guix-configuration-log-compression (default 'bzip2)) + (discover? guix-configuration-discover? + (default #f)) (extra-options guix-configuration-extra-options ;list of strings (default '())) (log-file guix-configuration-log-file ;string @@ -1571,8 +1573,8 @@ proxy of 'guix-daemon'...~%") (match-record config (guix build-group build-accounts authorize-key? authorized-keys use-substitutes? substitute-urls max-silent-time timeout - log-compression extra-options log-file http-proxy tmpdir - chroot-directories) + log-compression discover? extra-options log-file + http-proxy tmpdir chroot-directories) (list (shepherd-service (documentation "Run the Guix daemon.") (provision '(guix-daemon)) @@ -1606,6 +1608,9 @@ proxy of 'guix-daemon'...~%") #$@(if use-substitutes? '() '("--no-substitutes")) + #$@(if discover? + '("--discover=yes") + '()) "--substitute-urls" #$(string-join substitute-urls) #$@extra-options diff --git a/guix/scripts/discover.scm b/guix/scripts/discover.scm new file mode 100644 index 0000000000..b17dbdcb3c --- /dev/null +++ b/guix/scripts/discover.scm @@ -0,0 +1,158 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2020 Mathieu Othacehe +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix scripts discover) + #:use-module (guix avahi) + #:use-module (guix config) + #:use-module (guix scripts) + #:use-module (guix ui) + #:use-module (guix build syscalls) + #:use-module (guix build utils) + #:use-module (guix scripts publish) + #:use-module (ice-9 rdelim) + #:use-module (srfi srfi-37) + #:export (read-substitute-urls + + guix-discover)) + +(define (show-help) + (format #t (G_ "Usage: guix discover [OPTION]... +Discover Guix related services using Avahi.\n")) + (display (G_ " + -c, --cache=DIRECTORY cache discovery results in DIRECTORY")) + (display (G_ " + -h, --help display this help and exit")) + (display (G_ " + -V, --version display version information and exit")) + (newline) + (show-bug-report-information)) + +(define %options + (list (option '(#\c "cache") #t #f + (lambda (opt name arg result) + (alist-cons 'cache arg result))) + (option '(#\h "help") #f #f + (lambda _ + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda _ + (show-version-and-exit "guix discover"))))) + +(define %default-options + `((cache . ,%state-directory))) + + +;;; +;;; Publish servers. +;;; + +(define %publish-services + ;; Set of discovered publish services. + (make-hash-table)) + +(define (publish-file cache-directory) + "Return the name of the file storing the discovered publish services inside +CACHE-DIRECTORY." + (let ((directory (string-append cache-directory "/discover"))) + (string-append directory "/publish"))) + +(define %publish-file + (make-parameter (publish-file %state-directory))) + +(define* (write-publish-file #:key (file (%publish-file))) + "Dump the content of %PUBLISH-SERVICES hash table into FILE. Use a write +lock on FILE to synchronize with any potential readers." + (with-file-lock file + (call-with-output-file file + (lambda (port) + (hash-for-each + (lambda (name service) + (format port "http://~a:~a~%" + (avahi-service-address service) + (avahi-service-port service))) + %publish-services))) + (chmod file #o644))) + +(define (call-with-read-file-lock file thunk) + "Call THUNK with a read lock on FILE." + (let ((port #f)) + (dynamic-wind + (lambda () + (set! port + (let ((port (open-file file "r0"))) + (fcntl-flock port 'read-lock) + port))) + thunk + (lambda () + (when port + (unlock-file port)))))) + +(define-syntax-rule (with-read-file-lock file exp ...) + "Wait to acquire a read lock on FILE and evaluate EXP in that context." + (call-with-read-file-lock file (lambda () exp ...))) + +(define* (read-substitute-urls #:key (file (%publish-file))) + "Read substitute urls list from FILE and return it. Use a read lock on FILE +to synchronize with the writer." + (with-read-file-lock file + (call-with-input-file file + (lambda (port) + (let loop ((url (read-line port)) + (urls '())) + (if (eof-object? url) + urls + (loop (read-line port) (cons url urls)))))))) + + +;;; +;;; Entry point. +;;; + +(define %services + ;; List of services we want to discover. + (list publish-service-type)) + +(define (service-proc action service) + (let ((name (avahi-service-name service)) + (type (avahi-service-type service))) + (when (string=? type publish-service-type) + (case action + ((new-service) + (hash-set! %publish-services name service)) + ((remove-service) + (hash-remove! %publish-services name))) + (write-publish-file)))) + +(define-command (guix-discover . args) + (category internal) + (synopsis "discover Guix related services using Avahi") + + (with-error-handling + (let* ((opts (args-fold* args %options + (lambda (opt name arg result) + (leave (G_ "~A: unrecognized option~%") name)) + (lambda (arg result) + (leave (G_ "~A: extraneous argument~%") arg)) + %default-options)) + (cache (assoc-ref opts 'cache)) + (publish-file (publish-file cache))) + (parameterize ((%publish-file publish-file)) + (mkdir-p (dirname publish-file)) + (avahi-browse-service-thread service-proc + #:types %services))))) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index ddb885d344..8e5953b877 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -27,6 +27,7 @@ #:use-module (guix config) #:use-module (guix records) #:use-module ((guix serialization) #:select (restore-file)) + #:use-module (guix scripts discover) #:use-module (gcrypt hash) #:use-module (guix base32) #:use-module (guix base64) @@ -1078,9 +1079,38 @@ found." ;; daemon. '("http://ci.guix.gnu.org")))) +;; In order to prevent using large number of discovered local substitute +;; servers, limit the local substitute urls list size. +(define %max-substitute-urls 50) + +(define* (randomize-substitute-urls urls + #:key + (max %max-substitute-urls)) + "Return a list containing MAX urls from URLS, picked randomly. If URLS list +is shorter than MAX elements, then it is directly returned." + (define (random-item list) + (list-ref list (random (length list)))) + + (if (<= (length urls) max) + urls + (let loop ((res '()) + (urls urls)) + (if (eq? (length res) max) + res + (let ((url (random-item urls))) + (loop (cons url res) (delete url urls))))))) + +(define %local-substitute-urls + ;; If the following option is passed to the daemon, use the substitutes list + ;; provided by "guix discover" process. + (if (find-daemon-option "discover") + (randomize-substitute-urls (read-substitute-urls)) + '())) + (define substitute-urls ;; List of substitute URLs. - (make-parameter %default-substitute-urls)) + (make-parameter (append %local-substitute-urls + %default-substitute-urls))) (define (client-terminal-columns) "Return the number of columns in the client's terminal, if it is known, or a diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index cd949aca67..30d0e5d11d 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -89,6 +89,7 @@ builds derivations on behalf of its clients."); #define GUIX_OPT_TIMEOUT 18 #define GUIX_OPT_MAX_SILENT_TIME 19 #define GUIX_OPT_LOG_COMPRESSION 20 +#define GUIX_OPT_DISCOVER 21 static const struct argp_option options[] = { @@ -129,6 +130,8 @@ static const struct argp_option options[] = n_("disable compression of the build logs") }, { "log-compression", GUIX_OPT_LOG_COMPRESSION, "TYPE", 0, n_("use the specified compression type for build logs") }, + { "discover", GUIX_OPT_DISCOVER, "yes/no", OPTION_ARG_OPTIONAL, + n_("use substitute servers discovered on the local network") }, /* '--disable-deduplication' was known as '--disable-store-optimization' up to Guix 0.7 included, so keep the alias around. */ @@ -167,6 +170,8 @@ to live outputs") }, /* List of '--listen' options. */ static std::list listen_options; +static bool useDiscover = false; + /* Convert ARG to a Boolean value, or throw an error if it does not denote a Boolean. */ static bool @@ -261,6 +266,10 @@ parse_opt (int key, char *arg, struct argp_state *state) case GUIX_OPT_NO_BUILD_HOOK: settings.useBuildHook = false; break; + case GUIX_OPT_DISCOVER: + useDiscover = string_to_bool (arg); + settings.set("discover", arg); + break; case GUIX_OPT_DEBUG: verbosity = lvlDebug; break; @@ -506,6 +515,18 @@ using `--build-users-group' is highly recommended\n")); format ("extra chroot directories: '%1%'") % chroot_dirs); } + if (useDiscover) + { + Strings args; + + args.push_back("guix"); + args.push_back("discover"); + + startProcess([&]() { + execv(settings.guixProgram.c_str(), stringsToCharPtrs(args).data()); + }); + } + printMsg (lvlDebug, format ("automatic deduplication set to %1%") % settings.autoOptimiseStore); -- cgit v1.2.3 From 36826389105fb7cf9037c5214ed9a6e37c83ad57 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Sun, 29 Nov 2020 18:01:19 +0300 Subject: doc: Document zabbix-agent hostname change. This commit follows 8518a3692cbb9cd96d69c03e9de9ad6fdcfebbee. * doc/guix.texi (Monitoring Services)[zabbix-agent]: Set hostname to empty string. --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index da6caaa4f1..56a1a21bbb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22135,7 +22135,7 @@ Defaults to @samp{"zabbix"}. Unique, case sensitive hostname which is required for active checks and must match hostname as configured on the server. -Defaults to @samp{"Zabbix server"}. +Defaults to @samp{""}. @end deftypevr -- cgit v1.2.3 From e1c81203ca9aa8a6dedb7c539d3ff845626aadcc Mon Sep 17 00:00:00 2001 From: John Soo Date: Thu, 12 Nov 2020 21:16:48 -0800 Subject: processes: Put ChildProcess and ChildPID on separate lines. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/processes.scm (daemon-session->recutils): Put child process information in separate fields. * doc/guix.texi (Invoking guix processes): Document change in output of 'guix processes'. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 22 +++++++++++++--------- guix/scripts/processes.scm | 6 ++++-- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 56a1a21bbb..7cef2371ad 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -84,6 +84,7 @@ Copyright @copyright{} 2020 André Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* Copyright @copyright{} 2020 raingloom@* Copyright @copyright{} 2020 Daniel Brooks@* +Copyright @copyright{} 2020 John Soo@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -12865,9 +12866,12 @@ ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock -ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800 -ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800 -ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800 +ChildPID: 20495 +ChildCommand: guix offload x86_64-linux 7200 1 28800 +ChildPID: 27733 +ChildCommand: guix offload x86_64-linux 7200 1 28800 +ChildPID: 27793 +ChildCommand: guix offload x86_64-linux 7200 1 28800 @end example In this example we see that @command{guix-daemon} has three clients: @@ -12876,12 +12880,12 @@ integration tool; their process identifier (PID) is given by the @code{ClientPID} field. The @code{SessionPID} field gives the PID of the @command{guix-daemon} sub-process of this particular session. -The @code{LockHeld} fields show which store items are currently locked by this -session, which corresponds to store items being built or substituted (the -@code{LockHeld} field is not displayed when @command{guix processes} is not -running as root). Last, by looking at the @code{ChildProcess} field, we -understand that these three builds are being offloaded (@pxref{Daemon Offload -Setup}). +The @code{LockHeld} fields show which store items are currently locked +by this session, which corresponds to store items being built or +substituted (the @code{LockHeld} field is not displayed when +@command{guix processes} is not running as root). Last, by looking at +the @code{ChildPID} and @code{ChildCommand} fields, we understand that +these three builds are being offloaded (@pxref{Daemon Offload Setup}). The output is in Recutils format so we can use the handy @command{recsel} command to select sessions of interest (@pxref{Selection Expressions,,, diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..3a7ea0b89c 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2020 John Soo ;;; ;;; This file is part of GNU Guix. ;;; @@ -188,8 +189,9 @@ active sessions, and the master 'guix-daemon' process." (format port "LockHeld: ~a~%" lock)) (daemon-session-locks-held session)) (for-each (lambda (process) - (format port "ChildProcess: ~a:~{ ~a~}~%" - (process-id process) + (format port "ChildPID: ~a~%" + (process-id process)) + (format port "ChildCommand: :~{ ~a~}~%" (process-command process))) (daemon-session-children session))) -- cgit v1.2.3 From 58be9e0bf1e58131e4e8d2b74f41b7b8e154b4b8 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: processes: Add '--format' and the "normalized" format. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/processes.scm (lock->recutils): New procedure. (daemon-session->recutils): Use it. (daemon-sessions->recutils, session-key->recutils) (session-scalars->normalized-record) (child-process->normalized-record) (daemon-sessions->normalized-record): New procedures. (session-rec-type, lock-rec-type, child-process-rec-type) (%available-formats): New variables. (list-formats): New procedure. (%options, show-help): Add '--format'. (%default-options): New variable. (guix-processes): Use 'parse-command-line' instead of 'args-fold*'. Honor the 'format' value in OPTIONS. * doc/guix.texi (Invoking guix processes): Document '--format'. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 39 ++++++++++++ guix/scripts/processes.scm | 146 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 166 insertions(+), 19 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 7cef2371ad..e7277fc9ee 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12899,6 +12899,45 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example +Additional options are listed below. + +@table @code +@item --format=@var{format} +@itemx -f @var{format} +Produce output in the specified @var{format}, one of: + +@table @code +@item recutils +The default option. It outputs a set of Session recutils records +that include each @code{ChildProcess} as a field. + +@item normalized +Normalize the output records into record sets (@pxref{Record Sets,,, +recutils, GNU recutils manual}). Normalizing into record sets allows +joins across record types. The example below lists the PID of each +@code{ChildProcess} and the associated PID for @code{Session} that +spawned the @code{ChildProcess} where the @code{Session} was started +using @command{guix build}. + +@example +$ guix processes --format=normalized | \ + recsel \ + -j Session \ + -t ChildProcess \ + -p Session.PID,PID \ + -e 'Session.ClientCommand ~ "guix build"' +PID: 4435 +Session_PID: 4278 + +PID: 4554 +Session_PID: 4278 + +PID: 4646 +Session_PID: 4278 +@end example +@end table +@end table + @node System Configuration @chapter System Configuration diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index 3a7ea0b89c..3db5603286 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -177,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) +(define (lock->recutils lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -185,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->recutils lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildPID: ~a~%" @@ -195,19 +197,102 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) +(define (daemon-sessions->recutils port sessions) + "Display denormalized SESSIONS information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + sessions)) + +(define session-rec-type + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID +%mandatory: ClientPID ClientCommand") + +(define lock-rec-type + "%rec: Lock +%mandatory: LockHeld +%type: Session rec Session") + +(define child-process-rec-type + "%rec: ChildProcess +%type: PID int +%type: Session rec Session +%key: PID +%mandatory: Command") + +(define (session-key->recutils session port) + "Display SESSION PID as a recutils field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(define (child-process->normalized-record process port) + "Display PROCESS record on PORT in normalized form" + (format port "PID: ~a" (process-id process)) + (newline port) + (format port "Command:~{ ~a~}" (process-command process))) + +(define (daemon-sessions->normalized-record port sessions) + "Display SESSIONS recutils on PORT in normalized form" + (display session-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (session-scalars->normalized-record session port) + (newline port)) + sessions) + + (display lock-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (lock) + (lock->recutils "testing testing" port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-locks-held session))) + sessions) + + (display child-process-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (process) + (child-process->normalized-record process port) + (newline port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. ;;; -(define %options - (list (option '(#\h "help") #f #f - (lambda args - (show-help) - (exit 0))) - (option '(#\V "version") #f #f - (lambda args - (show-version-and-exit "guix processes"))))) +(define %available-formats + '("recutils" "normalized")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) (define (show-help) (display (G_ "Usage: guix processes @@ -218,8 +303,33 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -f, --format=FORMAT display results as normalized record sets")) + (display (G_ " + --list-formats display available formats")) + (newline) (show-bug-report-information)) +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix processes"))) + (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg %available-formats) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))))) + +(define %default-options '((format . recutils))) + ;;; ;;; Entry point. @@ -228,18 +338,16 @@ List the current Guix sessions and their processes.")) (define-command (guix-processes . args) (category plumbing) (synopsis "list currently running sessions") + (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'format) + ('normalized + (daemon-sessions->normalized-record port (daemon-sessions))) + (_ (daemon-sessions->recutils port (daemon-sessions)))) ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) -- cgit v1.2.3 From 3462678bc346c2f6ea81245d6842264b6dccd945 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 29 Nov 2020 21:51:43 -0500 Subject: doc: Document that source derivation builds can be checked. It is a common mistake to modify an record that computes to a fixed-output derivation, forgetting to update its hash field, only to find out that a previously built source gets used instead. While there doesn't seem to be an obvious solution to this problem, we can at least document the fact that sources can be checked the same as other builds. * doc/guix.texi (Additional Build Options): Document that source derivation builds can be verified using --check. --- doc/guix.texi | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index e7277fc9ee..889f380108 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10424,6 +10424,13 @@ The returned source tarball is the result of applying any patches and code snippets specified in the package @code{origin} (@pxref{Defining Packages}). +@cindex source, verification +As with other derivations, the result of building a source derivation +can be verified using the @option{--check} option (@pxref{build-check}). +This is useful to validate that a (potentially already built or +substituted, thus cached) package source matches against its declared +hash. + Note that @command{guix build -S} compiles the sources only of the specified packages. They do not include the sources of statically linked dependencies and by themselves are insufficient for reproducing -- cgit v1.2.3 From 64f032d73f83727c0d06a1ea6531c226593ee976 Mon Sep 17 00:00:00 2001 From: raingloom Date: Tue, 13 Oct 2020 09:26:52 +0200 Subject: build-system: Add chicken-build-system. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/build-system/chicken.scm: New file. * guix/build/chicken-build-system.scm: New file. * Makefile.am: Add them. * doc/guix.texi: Document it. Signed-off-by: Ludovic Courtès --- Makefile.am | 2 + doc/guix.texi | 22 ++++++ guix/build-system/chicken.scm | 132 +++++++++++++++++++++++++++++++++++ guix/build/chicken-build-system.scm | 133 ++++++++++++++++++++++++++++++++++++ 4 files changed, 289 insertions(+) create mode 100644 guix/build-system/chicken.scm create mode 100644 guix/build/chicken-build-system.scm (limited to 'doc') diff --git a/Makefile.am b/Makefile.am index fc60d15561..1a3ca227a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -126,6 +126,7 @@ MODULES = \ guix/build-system/android-ndk.scm \ guix/build-system/ant.scm \ guix/build-system/cargo.scm \ + guix/build-system/chicken.scm \ guix/build-system/clojure.scm \ guix/build-system/cmake.scm \ guix/build-system/dub.scm \ @@ -175,6 +176,7 @@ MODULES = \ guix/build/download-nar.scm \ guix/build/cargo-build-system.scm \ guix/build/cargo-utils.scm \ + guix/build/chicken-build-system.scm \ guix/build/cmake-build-system.scm \ guix/build/dub-build-system.scm \ guix/build/dune-build-system.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 889f380108..9835d19d2b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7335,6 +7335,28 @@ parameters available to cargo. It will also remove an included defined by the crate. @end defvr +@defvr {Scheme Variable} chicken-build-system +This variable is exported by @code{(guix build-system chicken)}. +It builds Chicken Scheme modules (also called ``eggs'' or ``extensions''). +Chicken generates C source code, which then gets compiled by a C compiler, +in this case GCC. + +It adds @code{chicken} to the package inputs, as well as the packages of +@code{gnu-build-system}. + +The build system can't (yet) deduce the egg's name automatically, so just like +with @code{go-build-system} and its @code{#:import-path}, you should define +@code{#:egg-name} in the package's @code{arguments} field. + +For example, if you are packaging the srfi-1 egg: +@lisp +(arguments '(#:egg-name "srfi-1")) +@end lisp + +Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs} +because Chicken doesn't embed absolute references in compiled eggs. +Test dependecies should go to @code{native-inputs}, as usual. +@end defvr @defvr {Scheme Variable} copy-build-system This variable is exported by @code{(guix build-system copy)}. It diff --git a/guix/build-system/chicken.scm b/guix/build-system/chicken.scm new file mode 100644 index 0000000000..9abae0431a --- /dev/null +++ b/guix/build-system/chicken.scm @@ -0,0 +1,132 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2020 raingloom +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build-system chicken) + #:use-module (guix utils) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (guix packages) + #:use-module (ice-9 match) + #:export (%chicken-build-system-modules + chicken-build + chicken-build-system)) + +(define %chicken-build-system-modules + ;; Build-side modules imported and used by default. + `((guix build chicken-build-system) + (guix build union) + ,@%gnu-build-system-modules)) + +(define (default-chicken) + ;; Lazily resolve the binding to avoid a circular dependency. + ;; TODO is this actually needed in every build system? + (let ((chicken (resolve-interface '(gnu packages chicken)))) + (module-ref chicken 'chicken))) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (chicken (default-chicken)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #:chicken #:inputs #:native-inputs)) + + ;; TODO: cross-compilation support + (and (not target) + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + + ;; Keep the standard inputs of 'gnu-build-system', since + ;; Chicken compiles Scheme by using C as an intermediate + ;; language. + ,@(standard-packages))) + (build-inputs `(("chicken" ,chicken) + ,@native-inputs)) + (outputs outputs) + (build chicken-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define* (chicken-build store name inputs + #:key + (phases '(@ (guix build chicken-build-system) + %standard-phases)) + (outputs '("out")) + (search-paths '()) + (egg-name "") + (unpack-path "") + (build-flags ''()) + (tests? #t) + (system (%current-system)) + (guile #f) + (imported-modules %chicken-build-system-modules) + (modules '((guix build chicken-build-system) + (guix build union) + (guix build utils)))) + (define builder + `(begin + (use-modules ,@modules) + (chicken-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:system ,system + #:phases ,phases + #:outputs %outputs + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:egg-name ,egg-name + #:unpack-path ,unpack-path + #:build-flags ,build-flags + #:tests? ,tests? + #:inputs %build-inputs))) + + (define guile-for-build + (match guile + ((? package?) + (package-derivation store guile system #:graft? #f)) + (#f ; the default + (let* ((distro (resolve-interface '(gnu packages commencement))) + (guile (module-ref distro 'guile-final))) + (package-derivation store guile system + #:graft? #f))))) + + (build-expression->derivation store name builder + #:inputs inputs + #:system system + #:modules imported-modules + #:outputs outputs + #:guile-for-build guile-for-build)) + +(define chicken-build-system + (build-system + (name 'chicken) + (description + "Build system for Chicken Scheme programs") + (lower lower))) diff --git a/guix/build/chicken-build-system.scm b/guix/build/chicken-build-system.scm new file mode 100644 index 0000000000..5db9906acf --- /dev/null +++ b/guix/build/chicken-build-system.scm @@ -0,0 +1,133 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2020 raingloom +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build chicken-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build union) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:use-module (ice-9 ftw) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (rnrs io ports) + #:use-module (rnrs bytevectors) + #:export (%standard-phases + chicken-build)) + +;; CHICKEN_EGG_CACHE is where sources are fetched and binaries are built +;; CHICKEN_INSTALL_REPOSITORY is where dependencies are looked up +;; its first component is also where new eggs are installed. + +;; TODO: deduplicate with go-build-system.scm ? +;; TODO: the binary version should be defined in one of the relevant modules +;; instead of being hardcoded everywhere. Tried to do that but got undefined +;; variable errors. + +(define (chicken-package? name) + (string-prefix? "chicken-" name)) + +(define* (setup-chicken-environment #:key inputs outputs #:allow-other-keys) + (setenv "CHICKEN_INSTALL_REPOSITORY" + (string-concatenate + ;; see TODO item about binary version above + (append (list (assoc-ref outputs "out") "/var/lib/chicken/11/") + (let ((oldenv (getenv "CHICKEN_INSTALL_REPOSITORY"))) + (if oldenv + (list ":" oldenv) + '()))))) + (setenv "CHICKEN_EGG_CACHE" (getcwd)) + #t) + +;; This is copied from go-build-system.scm so it could probably be simplified. +;; I used it because the source of the egg needs to be unpacked into a directory +;; that is named after the egg and I knew that the go build system does that. +(define* (unpack #:key source egg-name unpack-path #:allow-other-keys) + "Relative to $CHICKEN_EGG_CACHE, unpack SOURCE in UNPACK-PATH, or EGG-NAME +when UNPACK-PATH is unset. If the SOURCE archive has a single top level +directory, it is stripped so that the sources appear directly under UNPACK-PATH. +When SOURCE is a directory, copy its content into UNPACK-PATH instead of +unpacking." + (define (unpack-maybe-strip source dest) + (let* ((scratch-dir (string-append (or (getenv "TMPDIR") "/tmp") + "/scratch-dir")) + (out (mkdir-p scratch-dir))) + (with-directory-excursion scratch-dir + (if (string-suffix? ".zip" source) + (invoke "unzip" source) + (invoke "tar" "-xvf" source)) + (let ((top-level-files (remove (lambda (x) + (member x '("." ".."))) + (scandir ".")))) + (match top-level-files + ((top-level-file) + (when (file-is-directory? top-level-file) + (copy-recursively top-level-file dest #:keep-mtime? #t))) + (_ + (copy-recursively "." dest #:keep-mtime? #t))))) + (delete-file-recursively scratch-dir))) + + (when (string-null? egg-name) + (display "WARNING: The egg name is unset.\n")) + (when (string-null? unpack-path) + (set! unpack-path egg-name)) + (let ((dest (string-append (getenv "CHICKEN_EGG_CACHE") "/" unpack-path))) + (mkdir-p dest) + (if (file-is-directory? source) + (copy-recursively source dest #:keep-mtime? #t) + (unpack-maybe-strip source dest))) + #t) + +(define* (build #:key egg-name #:allow-other-keys) + "Build the Chicken egg named by EGG-NAME" + (invoke "chicken-install" "-cached" "-no-install" egg-name)) + +(define* (install #:key egg-name #:allow-other-keys) + "Install the already built egg named by EGG-NAME" + (invoke "chicken-install" "-cached" egg-name)) + +(define* (check #:key egg-name tests? #:allow-other-keys) + "Build and run tests for the Chicken egg EGG-NAME" + ;; there is no "-test-only" option, but we've already run install + ;; so this just runs tests. + ;; i think it's a fair assumption that phases won't be reordered. + (setenv "CHICKEN_REPOSITORY_PATH" + (string-append (getenv "CHICKEN_INSTALL_REPOSITORY") + ":" + (getenv "CHICKEN_REPOSITORY_PATH"))) + (when tests? + (invoke "chicken-install" "-cached" "-test" "-no-install" egg-name))) + +;; It doesn't look like Chicken generates any unnecessary references. +;; So we don't have to remove them either. Nice. + +(define %standard-phases + (modify-phases gnu:%standard-phases + (replace 'unpack unpack) + (delete 'bootstrap) + (delete 'configure) + (delete 'patch-generated-file-shebangs) + (add-before 'unpack 'setup-chicken-environment setup-chicken-environment) + (replace 'build build) + (delete 'check) + (replace 'install install) + (add-after 'install 'check check))) + +(define* (chicken-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given Chicken package, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) -- cgit v1.2.3 From b5a6eddd8e9f2e840f47d3307f436433e74e16f3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 3 Dec 2020 16:15:00 +0100 Subject: doc: Tweak wording of 'chicken-build-system' material. * doc/guix.texi (Build Systems): Fix spelling of "CHICKEN". Add xref to its web site. Tweak wording. --- doc/guix.texi | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 9835d19d2b..80185e0731 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7336,26 +7336,27 @@ defined by the crate. @end defvr @defvr {Scheme Variable} chicken-build-system -This variable is exported by @code{(guix build-system chicken)}. -It builds Chicken Scheme modules (also called ``eggs'' or ``extensions''). -Chicken generates C source code, which then gets compiled by a C compiler, -in this case GCC. +This variable is exported by @code{(guix build-system chicken)}. It +builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called +``eggs'' or ``extensions''. CHICKEN generates C source code, which then +gets compiled by a C compiler, in this case GCC. -It adds @code{chicken} to the package inputs, as well as the packages of -@code{gnu-build-system}. +This build system adds @code{chicken} to the package inputs, as well as +the packages of @code{gnu-build-system}. The build system can't (yet) deduce the egg's name automatically, so just like with @code{go-build-system} and its @code{#:import-path}, you should define @code{#:egg-name} in the package's @code{arguments} field. -For example, if you are packaging the srfi-1 egg: +For example, if you are packaging the @code{srfi-1} egg: + @lisp (arguments '(#:egg-name "srfi-1")) @end lisp Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs} -because Chicken doesn't embed absolute references in compiled eggs. -Test dependecies should go to @code{native-inputs}, as usual. +because CHICKEN doesn't embed absolute references in compiled eggs. +Test dependencies should go to @code{native-inputs}, as usual. @end defvr @defvr {Scheme Variable} copy-build-system -- cgit v1.2.3 From 7776fc4c0f8c4b4c68598756a7282240aede7e75 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Thu, 3 Dec 2020 20:23:09 +0100 Subject: doc: Correct spelling of 'discover?' . * doc/guix.texi (Base Services): Correct spelling of 'discover?'. Signed-off-by: Mathieu Othacehe --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 80185e0731..1493c68e27 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -15111,7 +15111,7 @@ disables the timeout. The type of compression used for build logs---one of @code{gzip}, @code{bzip2}, or @code{none}. -@item @code{discover} (default: @code{#f}) +@item @code{discover?} (default: @code{#f}) Whether to discover substitute servers on the local network using mDNS and DNS-SD. -- cgit v1.2.3 From 1d4a2668e3a6b0db1137b213558642502c28d69e Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Tue, 1 Dec 2020 10:10:17 +0100 Subject: doc: Give references and examples for services-to-restart. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/guix.texi (Unattended Upgrades): Give references and examples for services-to-restart. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 1493c68e27..f4ed4ad3ed 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17198,6 +17198,10 @@ only restarts services that are not currently running, which is conservative: it minimizes disruption but leaves outdated services running. +Use @command{herd status} to find out candidates for restarting. +@xref{Services}, for general information about services. Common +services to restart would include @code{ntpd} and @code{ssh-daemon}. + By default, the @code{mcron} service is restarted. This ensures that the latest version of the unattended upgrade job will be used next time. -- cgit v1.2.3 From 443599999af21878d58dbb48210d4cccca2882d8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 4 Dec 2020 16:56:09 +0100 Subject: doc: Mention Guile-Semver dependency. This is a followup to 269c1db41bd82f93c7ae5c62a4969a423e556183. * doc/guix.texi (Requirements): Mention Guile-Semver. --- doc/guix.texi | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index f4ed4ad3ed..a5c9779c86 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -850,6 +850,10 @@ Support for build offloading (@pxref{Daemon Offload Setup}) and @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH}, version 0.13.0 or later. +@item +@uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for +the @code{crate} importer (@pxref{Invoking guix import}). + @item When @url{http://www.bzip.org, libbz2} is available, @command{guix-daemon} can use it to compress build logs. -- cgit v1.2.3 From 7f13e8d862e52f3b199b529f833a2bde362311a8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 5 Dec 2020 19:01:45 +0100 Subject: doc: Add note on the importance of bootstrapping. * doc/guix.texi (Bootstrapping): Remove distinction between "regular users" and "hackers". Explain the importance of the question. --- doc/guix.texi | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index a5c9779c86..b7187963b7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -32789,10 +32789,15 @@ Bootstrapping in our context refers to how the distribution gets built ``from nothing''. Remember that the build environment of a derivation contains nothing but its declared inputs (@pxref{Introduction}). So there's an obvious chicken-and-egg problem: how does the first package -get built? How does the first compiler get compiled? Note that this is -a question of interest only to the curious hacker, not to the regular -user, so you can shamelessly skip this section if you consider yourself -a ``regular user''. +get built? How does the first compiler get compiled? + +It is tempting to think of this question as one that only die-hard +hackers may care about. However, while the answer to that question is +technical in nature, its implications are wide-ranging. How the +distribution is bootstrapped defines the extent to which we, as +individuals and as a collective of users and hackers, can trust the +software we run. It is a central concern from the standpoint of +@emph{security} and from a @emph{user freedom} viewpoint. @cindex bootstrap binaries The GNU system is primarily made of C code, with libc at its core. The -- cgit v1.2.3 From a889e6a9bfb35641ef66950df414145bb92fa938 Mon Sep 17 00:00:00 2001 From: Hugo Thiessard Date: Sun, 6 Dec 2020 19:04:29 +0000 Subject: doc: Document Guix System F2FS root support. * doc/guix.texi (Keyboard Layout and Networking and Partitioning): Add F2FS to the footnote of Guix System's supported root file systems. Signed-off-by: Tobias Geerinckx-Rice --- doc/guix.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index b7187963b7..7e1b782ab6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2383,9 +2383,9 @@ bootloaders. Once you are done partitioning the target hard disk drive, you have to create a file system on the relevant partition(s)@footnote{Currently -Guix System only supports ext4, btrfs, and JFS file systems. In particular, -code that reads file system UUIDs and labels only works for these file system -types.}. For the ESP, if you have one and assuming it is +Guix System only supports ext4, btrfs, JFS, and F2FS file systems. In +particular, code that reads file system UUIDs and labels only works for these +file system types.}. For the ESP, if you have one and assuming it is @file{/dev/sda1}, run: @example -- cgit v1.2.3 From 6eba27f7beb1320b1abd6123d969663e5a460f77 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 28 Nov 2020 10:52:13 +0000 Subject: doc: Remove redundant node exporter configuration from the example. * doc/guix.texi (Prometheus Node Exporter Service): Simplify the example. --- doc/guix.texi | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 7e1b782ab6..b5340aa368 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22021,13 +22021,10 @@ where monitoring these statistics is desirable. @defvar {Scheme variable} prometheus-node-exporter-service-type This is the service type for the @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter} -service, its value must be a @code{prometheus-node-exporter-configuration} -record as in this example: +service, its value must be a @code{prometheus-node-exporter-configuration}. @lisp -(service prometheus-node-exporter-service-type - (prometheus-node-exporter-configuration - (web-listen-address ":9100"))) +(service prometheus-node-exporter-service-type) @end lisp @end defvar -- cgit v1.2.3 From fd14385581e4f3f8285442a0e1cc17d320d35fa9 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 28 Nov 2020 10:58:02 +0000 Subject: prometheus-node-exporter: Enable the textfile collector. * gnu/services/monitoring.scm (): Add textfile-directory. (prometheus-node-exporter-textfile-directory, prometheus-node-exporter-activation): New procedures. (prometheus-node-exporter-shepherd-service): Pass --collector.textfile.directoryto the service. (prometheus-node-exporter-service-type): Extend the activation service type. * doc/guix.texi (Prometheus Node Exporter Service): Document. --- doc/guix.texi | 5 +++++ gnu/services/monitoring.scm | 27 ++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index b5340aa368..13e0dcf6b7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22038,6 +22038,11 @@ The prometheus-node-exporter package to use. @item @code{web-listen-address} (default: @code{":9100"}) Bind the web interface to the specified address. +@item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"}) +This directory can be used to export metrics specific to this machine. +Files containing metrics in the text format, with the filename ending in +@code{.prom} should be placed in this directory. + @end table @end deftp diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index faa1e71dcb..a7fd4328cf 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -126,7 +126,9 @@ HTTP.") (package prometheus-node-exporter-configuration-package (default go-github-com-prometheus-node-exporter)) (web-listen-address prometheus-node-exporter-web-listen-address - (default ":9100"))) + (default ":9100")) + (textfile-directory prometheus-node-exporter-textfile-directory + (default "/var/lib/prometheus/node-exporter"))) (define %prometheus-node-exporter-accounts (list (user-account @@ -143,7 +145,7 @@ HTTP.") (define prometheus-node-exporter-shepherd-service (match-lambda (( $ - package web-listen-address) + package web-listen-address textfile-directory) (list (shepherd-service (documentation "Prometheus node exporter.") @@ -151,12 +153,29 @@ HTTP.") (requirement '(networking)) (start #~(make-forkexec-constructor (list #$(file-append package "/bin/node_exporter") - "--web.listen-address" #$web-listen-address) + "--web.listen-address" #$web-listen-address + #$@(if textfile-directory + (list "--collector.textfile.directory" + textfile-directory) + '())) #:user "prometheus-node-exporter" #:group "prometheus-node-exporter" #:log-file "/var/log/prometheus-node-exporter.log")) (stop #~(make-kill-destructor))))))) +(define (prometheus-node-exporter-activation config) + (with-imported-modules '((guix build utils)) + #~(let ((textfile-directory + #$(prometheus-node-exporter-textfile-directory config))) + (use-modules (guix build utils)) + + (when textfile-directory + (let ((user (getpw "prometheus-node-exporter"))) + #t + (mkdir-p textfile-directory) + (chown textfile-directory (passwd:uid user) (passwd:gid user)) + (chmod textfile-directory #o775)))))) + (define prometheus-node-exporter-service-type (service-type (name 'prometheus-node-exporter) @@ -167,6 +186,8 @@ Prometheus.") (list (service-extension account-service-type (const %prometheus-node-exporter-accounts)) + (service-extension activation-service-type + prometheus-node-exporter-activation) (service-extension shepherd-root-service-type prometheus-node-exporter-shepherd-service))) (default-value (prometheus-node-exporter-configuration)))) -- cgit v1.2.3 From 92f7c11af26580a7e6543efa94531652f187923a Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 28 Nov 2020 11:03:19 +0000 Subject: prometheus-node-exporter: Support extra options. There are plenty of options supported that the Guix configuration record doesn't help you with, so add this field to allow users to do their own thing. * gnu/services/monitoring.scm (): Add extra-options field. (prometheus-node-exporter-shepherd-service): Handle the extra options. * doc/guix.texi (Prometheus Node Exporter Service): Document this. --- doc/guix.texi | 3 +++ gnu/services/monitoring.scm | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 13e0dcf6b7..a4386adf42 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22043,6 +22043,9 @@ This directory can be used to export metrics specific to this machine. Files containing metrics in the text format, with the filename ending in @code{.prom} should be placed in this directory. +@item @code{extra-options} (default: @code{'()}) +Extra options to pass to the Prometheus node exporter. + @end table @end deftp diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index a7fd4328cf..5123a8c441 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -128,7 +128,9 @@ HTTP.") (web-listen-address prometheus-node-exporter-web-listen-address (default ":9100")) (textfile-directory prometheus-node-exporter-textfile-directory - (default "/var/lib/prometheus/node-exporter"))) + (default "/var/lib/prometheus/node-exporter")) + (extra-options prometheus-node-exporter-extra-options + (default '()))) (define %prometheus-node-exporter-accounts (list (user-account @@ -145,7 +147,7 @@ HTTP.") (define prometheus-node-exporter-shepherd-service (match-lambda (( $ - package web-listen-address textfile-directory) + package web-listen-address textfile-directory extra-options) (list (shepherd-service (documentation "Prometheus node exporter.") @@ -157,7 +159,8 @@ HTTP.") #$@(if textfile-directory (list "--collector.textfile.directory" textfile-directory) - '())) + '()) + #$@extra-options) #:user "prometheus-node-exporter" #:group "prometheus-node-exporter" #:log-file "/var/log/prometheus-node-exporter.log")) -- cgit v1.2.3 From e461d3b750080b03f3deea0b44b99c2fda9767ab Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 4 Dec 2020 09:43:17 +0100 Subject: service: Add shepherd discover action. * gnu/services/base.scm (shepherd-discover-action): New procedure, (guix-shepherd-service)[]: add it, []: honor it. * doc/guix.texi (Invoking guix-daemon): Document it. --- doc/guix.texi | 8 ++++++++ gnu/services/base.scm | 32 ++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index a4386adf42..a21c4d614e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1606,6 +1606,14 @@ Servers may serve substitute over HTTP, unencrypted, so anyone on the LAN can see what software you’re installing. @end enumerate +It is also possible to enable or disable substitute server discovery at +run-time by running: + +@example +herd discover guix-daemon on +herd discover guix-daemon off +@end example + @item --disable-deduplication @cindex deduplication Disable automatic file ``deduplication'' in the store. diff --git a/gnu/services/base.scm b/gnu/services/base.scm index d0d88e18a6..709d011f53 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1568,6 +1568,27 @@ proxy of 'guix-daemon'...~%") (environ environment) #t))))) +(define shepherd-discover-action + ;; Shepherd action to enable or disable substitute servers discovery. + (shepherd-action + (name 'discover) + (documentation + "Enable or disable substitute servers discovery and restart the +'guix-daemon'.") + (procedure #~(lambda* (_ status) + (let ((environment (environ))) + (if (and status + (string=? status "on")) + (begin + (format #t "enable substitute servers discovery~%") + (setenv "discover" "on")) + (begin + (format #t "disable substitute servers discovery~%") + (unsetenv "discover"))) + (action 'guix-daemon 'restart) + (environ environment) + #t))))) + (define (guix-shepherd-service config) "Return a for the Guix daemon service with CONFIG." (match-record config @@ -1579,7 +1600,8 @@ proxy of 'guix-daemon'...~%") (documentation "Run the Guix daemon.") (provision '(guix-daemon)) (requirement '(user-processes)) - (actions (list shepherd-set-http-proxy-action)) + (actions (list shepherd-set-http-proxy-action + shepherd-discover-action)) (modules '((srfi srfi-1) (ice-9 match) (gnu build shepherd))) @@ -1594,6 +1616,9 @@ proxy of 'guix-daemon'...~%") ;; the 'set-http-proxy' action. (or (getenv "http_proxy") #$http-proxy)) + (define discover? + (or (getenv "discover") #$discover?)) + ;; Start the guix-daemon from a container, when supported, ;; to solve an installation issue. See the comment below for ;; more details. @@ -1608,9 +1633,8 @@ proxy of 'guix-daemon'...~%") #$@(if use-substitutes? '() '("--no-substitutes")) - #$@(if discover? - '("--discover=yes") - '()) + (string-append "--discover=" + (if discover? "yes" "no")) "--substitute-urls" #$(string-join substitute-urls) #$@extra-options -- cgit v1.2.3 From b3f21eb6bc895a4eafe903dfbb480de481bbb4c7 Mon Sep 17 00:00:00 2001 From: Holger Peters Date: Fri, 4 Dec 2020 10:51:37 +0100 Subject: doc: Fix incorrect GUIX_PROFILE value for 'guix pull'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/guix.texi (Getting Started): Fix invalid GUIX_PROFILE value. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index a21c4d614e..1f33fd3b76 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2786,7 +2786,7 @@ the command prints and, similar to what we saw above, paste these two lines in your terminal and @file{.bash_profile}: @example -GUIX_PROFILE="$HOME/.config/guix/current/etc/profile" +GUIX_PROFILE="$HOME/.config/guix/current" . "$GUIX_PROFILE/etc/profile" @end example -- cgit v1.2.3 From c46b969120265957ab8331c5ea1fd6006202276e Mon Sep 17 00:00:00 2001 From: 宋文武 Date: Mon, 7 Dec 2020 19:11:03 +0800 Subject: doc: Document about xfce4-panel plugins. * doc/guix.texi (Desktop Services): Document that xfce4-panel plugin packages should be added to the 'packages' field of OS. --- doc/guix.texi | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 1f33fd3b76..fc57f4f537 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -18563,6 +18563,12 @@ This service adds the @code{xfce} package to the system profile, and extends polkit with the ability for @code{thunar} to manipulate the file system as root from within a user session, after the user has authenticated with the administrator's password. + +Note that @code{xfce4-panel} and its plugin packages should be installed in +the same profile to ensure compatibility. When using this service, you should +add extra plugins (@code{xfce4-whiskermenu-plugin}, +@code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your +@code{operating-system}. @end defvr @deftp {Data Type} xfce-desktop-configuration -- cgit v1.2.3 From 770fb659a62d8adab9a4ba7b44e2760722703879 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 8 Dec 2020 11:53:25 +0100 Subject: services: cuirass: Add queue-size option. * gnu/services/cuirass.scm (): Add "queue-size" field. (cuirass-shepherd-service): Honor it. * doc/guix.texi (Continuous Integration): Document it. --- doc/guix.texi | 3 +++ gnu/services/cuirass.scm | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index fc57f4f537..0e647a284c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -25695,6 +25695,9 @@ Owner's group of the @code{cuirass} process. Number of seconds between the poll of the repositories followed by the Cuirass jobs. +@item @code{queue-size} (default: @code{1}) +Size of the database writer queue. + @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"}) Location of sqlite database which contains the build results and previously added specifications. diff --git a/gnu/services/cuirass.scm b/gnu/services/cuirass.scm index a50f583807..7706ed41c6 100644 --- a/gnu/services/cuirass.scm +++ b/gnu/services/cuirass.scm @@ -69,6 +69,8 @@ (default "cuirass")) (interval cuirass-configuration-interval ;integer (seconds) (default 60)) + (queue-size cuirass-configuration-queue-size + (default 1)) (database cuirass-configuration-database ;string (file-name) (default "/var/lib/cuirass/cuirass.db")) (port cuirass-configuration-port ;integer (port) @@ -98,6 +100,7 @@ (user (cuirass-configuration-user config)) (group (cuirass-configuration-group config)) (interval (cuirass-configuration-interval config)) + (queue-size (cuirass-configuration-queue-size config)) (database (cuirass-configuration-database config)) (ttl (cuirass-configuration-ttl config)) (port (cuirass-configuration-port config)) @@ -119,6 +122,7 @@ "--database" #$database "--ttl" #$(string-append (number->string ttl) "s") "--interval" #$(number->string interval) + "--queue-size" #$(number->string queue-size) #$@(if queries-log-file (list (string-append "--log-queries=" queries-log-file)) -- cgit v1.2.3 From ccc4d287b7bd2a3ddea7b7f2c1ea2a722e68115c Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Tue, 8 Dec 2020 15:03:47 +0100 Subject: guix: opam: Add coq support in the importer. * guix/import/opam.scm (get-opam-repository): Add support for coq repositories. (ocaml-name->guix-name): Properly name coq package. * doc/guix.texi (Invoking guix import): Document it. --- doc/guix.texi | 19 +++++++++++++++++++ guix/import/opam.scm | 8 ++++++++ 2 files changed, 27 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 0e647a284c..7960143723 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11291,6 +11291,25 @@ in Guix. @cindex OCaml Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package repository used by the OCaml community. + +Additional options include: + +@table @code +@item --recursive +@itemx -r +Traverse the dependency graph of the given upstream package recursively +and generate package expressions for all those packages that are not yet +in Guix. +@item --repo +Select the given repository (a repository name). Possible values include: +@itemize +@item @code{opam}, the default opam repository, +@item @code{coq} or @code{coq-released}, the stable repository for coq packages, +@item @code{coq-core-dev}, the repository that contains development versions of coq, +@item @code{coq-extra-dev}, the repository that contains development versions + of coq packages. +@end itemize +@end table @end table The structure of the @command{guix import} code is modular. It would be diff --git a/guix/import/opam.scm b/guix/import/opam.scm index 6f5c95df3b..54143f83ca 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -126,12 +126,19 @@ path to the repository." (let ((url (cond ((or (not repo) (equal? repo 'opam)) "https://github.com/ocaml/opam-repository") + ((string-prefix? "coq-" (symbol->string repo)) + "https://github.com/coq/opam-coq-archive") + ((equal? repo 'coq) "https://github.com/coq/opam-coq-archive") (else (throw 'unknown-repository repo))))) (receive (location commit _) (update-cached-checkout url) (cond ((or (not repo) (equal? repo 'opam)) location) + ((equal? repo 'coq) + (string-append location "/released")) + ((string-prefix? "coq-" (symbol->string repo)) + (string-append location "/" (substring (symbol->string repo) 4))) (else location))))) (define (latest-version versions) @@ -168,6 +175,7 @@ path to the repository." (substitute-char (cond ((equal? name "ocamlfind") "ocaml-findlib") + ((equal? name "coq") name) ((string-prefix? "ocaml" name) name) ((string-prefix? "conf-" name) (substring name 5)) (else (string-append "ocaml-" name))) -- cgit v1.2.3 From 69a0440a02945b3fb8d156b7f9d96628059d5f67 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 9 Dec 2020 11:58:01 +0100 Subject: doc: Document 'advertise?' for 'guix-publish-configuration'. * doc/guix.texi (Base Services): Document the 'advertise?' field of 'guix-publish-configuration'. --- doc/guix.texi | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 7960143723..38927bc0b5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -15353,6 +15353,14 @@ The TCP port to listen for connections. The host (and thus, network interface) to listen to. Use @code{"0.0.0.0"} to listen on all the network interfaces. +@item @code{advertise?} (default: @code{#f}) +When true, advertise the service on the local network @i{via} the DNS-SD +protocol, using Avahi. + +This allows neighboring Guix devices with discovery on (see +@code{guix-configuration} above) to discover this @command{guix publish} +instance and to automatically download substitutes from it. + @item @code{compression} (default: @code{'(("gzip" 3))}) This is a list of compression method/level tuple used when compressing substitutes. For example, to compress all substitutes with @emph{both} lzip -- cgit v1.2.3 From f06f569aa27ff0642948c8bb6fcca78807046f3d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 14 Dec 2020 12:19:05 +0100 Subject: doc: Link to "Pattern Matching" in Guile. * doc/contributing.texi (Data Types and Pattern Matching): Link to the "Pattern Matching" node of the Guile manual. --- doc/contributing.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/contributing.texi b/doc/contributing.texi index d8de71055a..866d2dae6b 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -864,7 +864,8 @@ to proper type error reports. Guix code should define appropriate data types (for instance, using @code{define-record-type*}) rather than abuse lists. In addition, it should use pattern matching, via Guile’s @code{(ice-9 match)} module, -especially when matching lists. +especially when matching lists (@pxref{Pattern Matching,,, guile, GNU +Guile Reference Manual}). @node Formatting Code @subsection Formatting Code -- cgit v1.2.3 From 48cccf06ad84f96bb4fc839ab6f26525c7e8dae0 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Mon, 14 Dec 2020 19:08:20 +0100 Subject: doc: Note different texlive-tiny & texline-union natures. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/contributing.texi (Submitting Patches): Add ‘package’ and ‘procedure’. Inspired-by: Jorge P. de Morais Neto --- doc/contributing.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/contributing.texi b/doc/contributing.texi index 866d2dae6b..78d9990b30 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -1009,7 +1009,7 @@ to other packages unwillingly retained. It may also help determine whether to split the package (@pxref{Packages with Multiple Outputs}), and which optional dependencies should be used. In particular, avoid adding @code{texlive} as a dependency: because of its extreme size, use -@code{texlive-tiny} or @code{texlive-union} instead. +the @code{texlive-tiny} package or @code{texlive-union} procedure instead. @item For important changes, check that dependent package (if applicable) are -- cgit v1.2.3 From 15fba3b13d543bbc1f13907e659c354a5b6f28ec Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Wed, 16 Dec 2020 14:31:12 -0500 Subject: doc: Add Emacs packaging guidelines. * doc/contributing.texi (Emacs Packages): New subsection. --- doc/contributing.texi | 41 +++++++++++++++++++++++++++++++++++++++++ doc/guix.texi | 1 + 2 files changed, 42 insertions(+) (limited to 'doc') diff --git a/doc/contributing.texi b/doc/contributing.texi index 78d9990b30..6500bfa3a1 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -391,6 +391,7 @@ needed is to review and apply the patch. * Version Numbers:: When the name is not enough. * Synopses and Descriptions:: Helping users find the right package. * Snippets versus Phases:: Whether to use a snippet, or a build phase. +* Emacs Packages:: Your Elisp fix. * Python Modules:: A touch of British comedy. * Perl Modules:: Little pearls. * Java Packages:: Coffee break. @@ -636,6 +637,46 @@ embed store items in the sources; such patching should rather be done using build phases. Refer to the @code{origin} record documentation for more information (@pxref{origin Reference}). +@node Emacs Packages +@subsection Emacs Packages + +@cindex emacs, packaging +@cindex elisp, packaging +Emacs packages should preferably use the Emacs build system +(@pxref{emacs-build-system}), for uniformity and the benefits provided +by its build phases, such as the auto-generation of the autoloads file +and the byte compilation of the sources. Because there are no +standardized way to run a test suite for Emacs packages, tests are +disabled by default. When a test suite is available, it should be +enabled by setting the @code{#:tests?} argument to @code{#true}. By +default, the command to run the test is @command{make check}, but any +command can be specified via the @code{#:test-command} argument. The +@code{#:test-command} argument expects a list containing a command and +its arguments, to be invoked during the @code{'check} phase. + +The Elisp dependencies of Emacs packages are typically provided as +@code{propagated-inputs} when required at run time. As for other +packages, build or test dependencies should be specified as +@code{native-inputs}. + +Emacs packages sometimes depend on resources directories that should be +installed along the Elisp files. The @code{#:include} argument can be +used for that purpose, by specifying a list of regexps to match. The +best practice when using the @code{#:include} argument is to extend +rather than override its default value (accessible via the +@code{%default-include} variable). As an example, a yasnippet extension +package typically include a @file{snippets} directory, which could be +copied to the installation directory using: + +@lisp +#:include (cons "^snippets/" %default-include)) +@end lisp + +When encountering problems, it is wise to check for the presence of the +@code{Package-Requires} extension header in the package main source +file, and whether any dependencies and their versions listed therein are +satisfied. + @node Python Modules @subsection Python Modules diff --git a/doc/guix.texi b/doc/guix.texi index 38927bc0b5..392baf5910 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7930,6 +7930,7 @@ Which D compiler is used can be specified with the @code{#:ldc} parameter which defaults to @code{ldc}. @end defvr +@anchor{emacs-build-system} @defvr {Scheme Variable} emacs-build-system This variable is exported by @code{(guix build-system emacs)}. It implements an installation procedure similar to the packaging system -- cgit v1.2.3 From eea7cc3185282b494a964eee4d6b3554f8eda0aa Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 17 Dec 2020 10:01:47 +0100 Subject: doc: Emacs Packages: Fix typos. * doc/contributing.texi (Emacs Packages): Fix typo. Also remove spurious white space, and unnecessary quote. --- doc/contributing.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/contributing.texi b/doc/contributing.texi index 6500bfa3a1..4195cb4105 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -645,14 +645,14 @@ more information (@pxref{origin Reference}). Emacs packages should preferably use the Emacs build system (@pxref{emacs-build-system}), for uniformity and the benefits provided by its build phases, such as the auto-generation of the autoloads file -and the byte compilation of the sources. Because there are no +and the byte compilation of the sources. Because there is no standardized way to run a test suite for Emacs packages, tests are disabled by default. When a test suite is available, it should be -enabled by setting the @code{#:tests?} argument to @code{#true}. By +enabled by setting the @code{#:tests?} argument to @code{#true}. By default, the command to run the test is @command{make check}, but any command can be specified via the @code{#:test-command} argument. The @code{#:test-command} argument expects a list containing a command and -its arguments, to be invoked during the @code{'check} phase. +its arguments, to be invoked during the @code{check} phase. The Elisp dependencies of Emacs packages are typically provided as @code{propagated-inputs} when required at run time. As for other -- cgit v1.2.3 From 5f5e3873d735d13824c172d779e6095d6947f340 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 17 Dec 2020 10:40:30 +0100 Subject: import/cran: Add input style "specification". * guix/import/cran.scm (%input-style): New parameter. (format-inputs): Use it. * guix/scripts/import/cran.scm (guix-import-cran): Set the %input-style parameter. (%options): Add "--style" option. * doc/guix.texi (Invoking guix import): Document it. --- doc/guix.texi | 7 +++++++ guix/import/cran.scm | 13 +++++++++++-- guix/scripts/import/cran.scm | 45 ++++++++++++++++++++++++-------------------- 3 files changed, 43 insertions(+), 22 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 392baf5910..74cd86be37 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11009,6 +11009,13 @@ When @option{--recursive} is added, the importer will traverse the dependency graph of the given upstream package recursively and generate package expressions for all those packages that are not yet in Guix. +When @option{--style=specification} is added, the importer will generate +package definitions whose inputs are package specifications instead of +references to package variables. This is useful when generated package +definitions are to be appended to existing user modules, as the list of +used package modules need not be changed. The default is +@option{--style=variable}. + When @option{--archive=bioconductor} is added, metadata is imported from @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R packages for the analysis and comprehension of high-throughput diff --git a/guix/import/cran.scm b/guix/import/cran.scm index 9d38be7a1e..fd44d80915 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -51,7 +51,9 @@ #:use-module (guix upstream) #:use-module (guix packages) #:use-module (gnu packages) - #:export (cran->guix-package + #:export (%input-style + + cran->guix-package bioconductor->guix-package cran-recursive-import %cran-updater @@ -74,6 +76,9 @@ ;;; ;;; Code: +(define %input-style + (make-parameter 'variable)) ; or 'specification + (define string->license (match-lambda ("AGPL-3" 'agpl3+) @@ -128,7 +133,11 @@ (define (format-inputs names) "Generate a sorted list of package inputs from a list of package NAMES." (map (lambda (name) - (list name (list 'unquote (string->symbol name)))) + (case (%input-style) + ((specification) + (list name (list 'unquote (list 'specification->package name)))) + (else + (list name (list 'unquote (string->symbol name)))))) (sort names string-cisymbol arg) (alist-delete 'repo result)))) + (option '(#\s "style") #t #f + (lambda (opt name arg result) + (alist-cons 'style (string->symbol arg) + (alist-delete 'style result)))) (option '(#\r "recursive") #f #f (lambda (opt name arg result) (alist-cons 'recursive #t result))) @@ -93,23 +97,24 @@ Import and convert the CRAN package for PACKAGE-NAME.\n")) value) (_ #f)) (reverse opts)))) - (match args - ((package-name) - (if (assoc-ref opts 'recursive) - ;; Recursive import - (with-error-handling - (map package->definition - (filter identity - (cran-recursive-import package-name - #:repo (or (assoc-ref opts 'repo) 'cran))))) - ;; Single import - (let ((sexp (cran->guix-package package-name - #:repo (or (assoc-ref opts 'repo) 'cran)))) - (unless sexp - (leave (G_ "failed to download description for package '~a'~%") - package-name)) - sexp))) - (() - (leave (G_ "too few arguments~%"))) - ((many ...) - (leave (G_ "too many arguments~%")))))) + (parameterize ((%input-style (assoc-ref opts 'style))) + (match args + ((package-name) + (if (assoc-ref opts 'recursive) + ;; Recursive import + (with-error-handling + (map package->definition + (filter identity + (cran-recursive-import package-name + #:repo (or (assoc-ref opts 'repo) 'cran))))) + ;; Single import + (let ((sexp (cran->guix-package package-name + #:repo (or (assoc-ref opts 'repo) 'cran)))) + (unless sexp + (leave (G_ "failed to download description for package '~a'~%") + package-name)) + sexp))) + (() + (leave (G_ "too few arguments~%"))) + ((many ...) + (leave (G_ "too many arguments~%"))))))) -- cgit v1.2.3 From af67e8d0b12d164d521c0910a6ae8a8e7d941099 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Wed, 23 Dec 2020 11:45:06 +0100 Subject: doc: cookbook: Fix "fiction-less" typo. * doc/guix-cookbook.texi (Guix Profiles in Practice): Change "friction-less" to "frictionless". --- doc/guix-cookbook.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index 581b8c3595..54ab99558e 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -2245,7 +2245,7 @@ section on @ref{Reproducible profiles}. @item Easier upgrades and maintenance: Multiple profiles make it easy to keep -package listings at hand and make upgrades completely friction-less. +package listings at hand and make upgrades completely frictionless. @end itemize Concretely, here follows some typical profiles: -- cgit v1.2.3 From 7624ebbae33cf49dded5e9032ed426781c9554f6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 18 Dec 2020 11:42:57 +0100 Subject: ssh: Use 'guix repl' instead of 'guile'. This simplifies setup of build machines: no need to install Guile in addition to Guix, no need to set 'GUILE_LOAD_PATH' & co., leading to fewer failure modes. * guix/ssh.scm (remote-run): New procedure. (remote-daemon-channel): Use it instead of 'open-remote-pipe*'. (store-import-channel)[import]: Remove check for module availability. Add call to 'primitive-exit'. Use 'remote-run' instead of 'open-remote-pipe'. (store-export-channel)[export]: Remove check for module availability. Add calls to 'primitive-exit'. Use 'remote-run' instead of 'open-remote-pipe'. (handle-import/export-channel-error): Remove 'module-error' clause. (report-module-error): Remove. * guix/scripts/offload.scm (assert-node-has-guix): Replace call to 'report-module-error' by 'leave'. * doc/guix.texi (Daemon Offload Setup): Remove mention of Guile. --- doc/guix.texi | 2 +- guix/scripts/offload.scm | 3 +- guix/ssh.scm | 91 +++++++++++++++++++++++++----------------------- 3 files changed, 51 insertions(+), 45 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 74cd86be37..b12cb11bdf 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1296,7 +1296,7 @@ master node: @end example This will attempt to connect to each of the build machines specified in -@file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are +@file{/etc/guix/machines.scm}, make sure Guix is available on each machine, attempt to export to the machine and import from it, and report any error in the process. diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index 58ee53e85c..835078cb97 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -634,7 +634,8 @@ daemon is not running." (and add-text-to-store 'alright)) node) ('alright #t) - (_ (report-module-error name))) + (_ (leave (G_ "(guix) module not usable on remote host '~a'") + name))) (match (inferior-eval '(begin (use-modules (guix)) diff --git a/guix/ssh.scm b/guix/ssh.scm index e41bffca65..457d1890f9 100644 --- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -54,8 +54,7 @@ retrieve-files* remote-store-host - report-guile-error - report-module-error)) + report-guile-error)) ;;; Commentary: ;;; @@ -206,6 +205,40 @@ REPL." ;; .) (close-inferior inferior))))) +(define (remote-run exp session) + "Run EXP in a new process in SESSION and return a remote pipe. + +Unlike 'inferior-remote-eval', this is used for side effects and may +communicate over stdout/stdin as it sees fit. EXP is typically a loop that +processes data from stdin and/or sends data to stdout. The assumption is that +EXP never returns or calls 'primitive-exit' when it's done." + (define pipe + (open-remote-pipe* session OPEN_BOTH + "guix" "repl" "-t" "machine")) + + (match (read pipe) + (('repl-version _ ...) + #t) + ((? eof-object?) + (close-port pipe) + (raise (formatted-message + (G_ "failed to start 'guix repl' on '~a'") + (session-get session 'host))))) + + ;; Disable buffering so 'guix repl' does not read more than what's really + ;; sent to itself. + (write '(setvbuf (current-input-port) 'none) pipe) + (force-output pipe) + + ;; Read the reply and subsequent newline. + (read pipe) (get-u8 pipe) + + (write exp pipe) + (force-output pipe) + + ;; From now on, we stop following the inferior protocol. + pipe) + (define* (remote-daemon-channel session #:optional (socket-name @@ -261,11 +294,7 @@ REPL." (_ (primitive-exit 1))))))) - (open-remote-pipe* session OPEN_BOTH - ;; Sort-of shell-quote REDIRECT. - "guile" "-c" - (object->string - (object->string redirect)))) + (remote-run redirect session)) (define* (connect-to-remote-daemon session #:optional @@ -288,11 +317,6 @@ can be written." ;; consumed. (define import `(begin - (eval-when (load expand eval) - (unless (resolve-module '(guix) #:ensure #f) - (write `(module-error)) - (exit 7))) - (use-modules (guix) (srfi srfi-34) (rnrs io ports) (rnrs bytevectors)) @@ -322,13 +346,10 @@ can be written." (import-paths store (current-input-port)) '(success)))) (lambda args - (cons 'error args)))))) + (cons 'error args)))) + (primitive-exit 0))) - (open-remote-pipe session - (string-join - `("guile" "-c" - ,(object->string (object->string import)))) - OPEN_BOTH)) + (remote-run import session)) (define* (store-export-channel session files #:key recursive?) @@ -338,22 +359,20 @@ be read. When RECURSIVE? is true, the closure of FILES is exported." ;; remote store. (define export `(begin - (eval-when (load expand eval) - (unless (resolve-module '(guix) #:ensure #f) - (write `(module-error)) - (exit 7))) - (use-modules (guix) (srfi srfi-1) (srfi srfi-26) (srfi srfi-34)) (guard (c ((nix-connection-error? c) (write `(connection-error ,(nix-connection-error-file c) - ,(nix-connection-error-code c)))) + ,(nix-connection-error-code c))) + (primitive-exit 1)) ((nix-protocol-error? c) (write `(protocol-error ,(nix-protocol-error-status c) - ,(nix-protocol-error-message c)))) + ,(nix-protocol-error-message c))) + (primitive-exit 2)) (else - (write `(exception)))) + (write `(exception)) + (primitive-exit 3))) (with-store store (let* ((files ',files) (invalid (remove (cut valid-path? store <>) @@ -371,13 +390,10 @@ be read. When RECURSIVE? is true, the closure of FILES is exported." (setvbuf (current-output-port) 'none) (export-paths store files (current-output-port) - #:recursive? ,recursive?)))))) + #:recursive? ,recursive?) + (primitive-exit 0)))))) - (open-remote-input-pipe session - (string-join - `("guile" "-c" - ,(object->string - (object->string export)))))) + (remote-run export session)) (define (remote-system session) "Return the system type as expected by Nix, usually ARCHITECTURE-KERNEL, of @@ -563,8 +579,6 @@ REMOTE." (match sexp ((? eof-object?) (report-guile-error (remote-store-host remote))) - (('module-error . _) - (report-module-error (remote-store-host remote))) (('connection-error file code . _) (raise-error (G_ "failed to connect to '~A' on remote host '~A': ~a") file (remote-store-host remote) (strerror code))) @@ -626,15 +640,6 @@ LOCAL. When RECURSIVE? is true, retrieve the closure of FILES." check.") host))) -(define (report-module-error host) - "Report an error about missing Guix modules on HOST." - ;; TRANSLATORS: Leave "Guile" untranslated. - (raise-error (G_ "Guile modules not found on remote host '~A'") host - (=> (G_ "Make sure @code{GUILE_LOAD_PATH} includes Guix' -own module directory. Run @command{ssh ~A env | grep GUILE_LOAD_PATH} to -check.") - host))) - (define (report-inferior-exception exception host) "Report EXCEPTION, an &inferior-exception that occurred on HOST." (raise-error (G_ "exception occurred on remote host '~A': ~s") -- cgit v1.2.3 From e38d90d497e19e00263fa28961c688a433154386 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 21 Dec 2020 14:52:38 +0100 Subject: transformations: Add '--with-patch'. Suggested by Philippe Swartvagher . * guix/transformations.scm (transform-package-patches): New procedure. (%transformations): Add it as 'with-patch'. (%transformation-options, show-transformation-options-help/detailed): Add '--with-patch'. * tests/transformations.scm ("options->transformation, with-patch"): New test. * doc/guix.texi (Package Transformation Options): Document it. --- doc/guix.texi | 18 ++++++++++++++ guix/transformations.scm | 63 ++++++++++++++++++++++++++++++++++++++++++++++- tests/transformations.scm | 24 ++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index b12cb11bdf..6c681494a2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10357,6 +10357,24 @@ This is similar to @option{--with-branch}, except that it builds from @var{commit} rather than the tip of a branch. @var{commit} must be a valid Git commit SHA1 identifier or a tag. +@item --with-patch=@var{package}=@var{file} +Add @var{file} to the list of patches applied to @var{package}, where +@var{package} is a spec such as @code{python@@3.8} or @code{glibc}. +@var{file} must contain a patch; it is applied with the flags specified +in the @code{origin} of @var{package} (@pxref{origin Reference}), which +by default includes @code{-p1} (@pxref{patch Directories,,, diffutils, +Comparing and Merging Files}). + +As an example, the command below rebuilds Coreutils with the GNU C +Library (glibc) patched with the given patch: + +@example +guix build coreutils --with-patch=glibc=./glibc-frob.patch +@end example + +In this example, glibc itself as well as everything that leads to +Coreutils in the dependency graph is rebuilt. + @cindex test suite, skipping @item --without-tests=@var{package} Build @var{package} without running its tests. This can be useful in diff --git a/guix/transformations.scm b/guix/transformations.scm index d49041cf59..2385d3231e 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -41,6 +41,7 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-37) #:use-module (ice-9 match) + #:use-module (ice-9 vlist) #:export (options->transformation manifest-entry-with-transformations @@ -456,6 +457,60 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (rewrite obj) obj))) +(define (transform-package-patches specs) + "Return a procedure that, when passed a package, returns a package with +additional patches." + (define (package-with-extra-patches p patches) + (if (origin? (package-source p)) + (package/inherit p + (source (origin + (inherit (package-source p)) + (patches (append (map (lambda (file) + (local-file file)) + patches) + (origin-patches (package-source p))))))) + p)) + + (define (coalesce-alist alist) + ;; Coalesce multiple occurrences of the same key in ALIST. + (let loop ((alist alist) + (keys '()) + (mapping vlist-null)) + (match alist + (() + (map (lambda (key) + (cons key (vhash-fold* cons '() key mapping))) + (delete-duplicates (reverse keys)))) + (((key . value) . rest) + (loop rest + (cons key keys) + (vhash-cons key value mapping)))))) + + (define patches + ;; Spec/patch alist. + (coalesce-alist + (map (lambda (spec) + (match (string-tokenize spec %not-equal) + ((spec patch) + (cons spec (canonicalize-path patch))) + (_ + (raise (formatted-message + (G_ "~a: invalid package patch specification") + spec))))) + specs))) + + (define rewrite + (package-input-rewriting/spec + (map (match-lambda + ((spec . patches) + (cons spec (cut package-with-extra-patches <> patches)))) + patches))) + + (lambda (obj) + (if (package? obj) + (rewrite obj) + obj))) + (define %transformations ;; Transformations that can be applied to things to build. The car is the ;; key used in the option alist, and the cdr is the transformation @@ -469,7 +524,8 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (with-git-url . ,transform-package-source-git-url) (with-c-toolchain . ,transform-package-toolchain) (with-debug-info . ,transform-package-with-debug-info) - (without-tests . ,transform-package-tests))) + (without-tests . ,transform-package-tests) + (with-patch . ,transform-package-patches))) (define (transformation-procedure key) "Return the transformation procedure associated with KEY, a symbol such as @@ -509,6 +565,8 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (parser 'with-debug-info)) (option '("without-tests") #t #f (parser 'without-tests)) + (option '("with-patch") #t #f + (parser 'with-patch)) (option '("help-transform") #f #f (lambda _ @@ -537,6 +595,9 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (display (G_ " --with-git-url=PACKAGE=URL build PACKAGE from the repository at URL")) + (display (G_ " + --with-patch=PACKAGE=FILE + add FILE to the list of patches of PACKAGE")) (display (G_ " --with-c-toolchain=PACKAGE=TOOLCHAIN build PACKAGE and its dependents with TOOLCHAIN")) diff --git a/tests/transformations.scm b/tests/transformations.scm index 2d33bed7ae..9053deba41 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -26,6 +26,7 @@ #:use-module (guix build-system) #:use-module (guix build-system gnu) #:use-module (guix transformations) + #:use-module ((guix gexp) #:select (local-file? local-file-file)) #:use-module (guix ui) #:use-module (guix utils) #:use-module (guix git) @@ -372,6 +373,29 @@ (match (memq #:tests? (package-arguments tar)) ((#:tests? #f _ ...) #t)))))))) +(test-equal "options->transformation, with-patch" + (search-patches "glibc-locales.patch" "guile-relocatable.patch") + (let* ((dep (dummy-package "dep" + (source (dummy-origin)))) + (p (dummy-package "foo" + (inputs `(("dep" ,dep))))) + (patch1 (search-patch "glibc-locales.patch")) + (patch2 (search-patch "guile-relocatable.patch")) + (t (options->transformation + `((with-patch . ,(string-append "dep=" patch1)) + (with-patch . ,(string-append "dep=" patch2)) + (with-patch . ,(string-append "tar=" patch1)))))) + (let ((new (t p))) + (match (bag-direct-inputs (package->bag new)) + ((("dep" dep) ("tar" tar) _ ...) + (and (member patch1 + (filter-map (lambda (patch) + (and (local-file? patch) + (local-file-file patch))) + (origin-patches (package-source tar)))) + (map local-file-file + (origin-patches (package-source dep))))))))) + (test-end) ;;; Local Variables: -- cgit v1.2.3 From b4db11364185e035de3d8c335b1a66eddeeeb84c Mon Sep 17 00:00:00 2001 From: Jonathan Brielmaier Date: Sat, 5 Dec 2020 01:09:13 +0100 Subject: services: Add radicale-service-type. * gnu/services/mail.scm (radicale-configuration) (radicale-configuration?): New procedures. (%default-radicale-config-file) (radicale-service-type): New variables. * doc/guix.texi: Document it. --- doc/guix.texi | 25 ++++++++++++++++ gnu/services/mail.scm | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 105 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 6c681494a2..1081ed26a3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -85,6 +85,7 @@ Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* Copyright @copyright{} 2020 raingloom@* Copyright @copyright{} 2020 Daniel Brooks@* Copyright @copyright{} 2020 John Soo@* +Copyright @copyright{} 2020 Jonathan Brielmaier@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -21217,6 +21218,30 @@ Mailutils Manual}, for details. @end table @end deftp +@subsubheading Radicale Service +@cindex CalDAV +@cindex CardDAV + +@deffn {Scheme Variable} radicale-service-type +This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV +server whose value should be a @code{radicale-configuration}. +@end deffn + +@deftp {Data Type} radicale-configuration +Data type representing the configuration of @command{radicale}. + +@table @asis +@item @code{package} (default: @code{radicale}) +The package that provides @command{radicale}. + +@item @code{config-file} (default: @code{%default-radicale-config-file}) +File-like object of the configuration file to use, by default it will listen +on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at +@file{/var/lib/radicale/users} with no (@code{plain}) encryption. + +@end table +@end deftp + @node Messaging Services @subsection Messaging Services diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index 71fa975b5d..c0f6371104 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017 Carlo Zancanaro ;;; Copyright © 2017, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2019 Kristofer Buffington +;;; Copyright © 2020 Jonathan Brielmaier ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module (gnu system shadow) #:use-module (gnu packages mail) #:use-module (gnu packages admin) + #:use-module (gnu packages dav) #:use-module (gnu packages tls) #:use-module (guix records) #:use-module (guix packages) @@ -70,7 +72,12 @@ imap4d-configuration imap4d-configuration? imap4d-service-type - %default-imap4d-config-file)) + %default-imap4d-config-file + + radicale-configuration + radicale-configuration? + radicale-service-type + %default-radicale-config-file)) ;;; Commentary: ;;; @@ -1834,3 +1841,75 @@ exim_group = exim (list (service-extension shepherd-root-service-type imap4d-shepherd-service))) (default-value (imap4d-configuration)))) + + +;;; +;;; Radicale. +;;; + +(define-record-type* + radicale-configuration make-radicale-configuration + radicale-configuration? + (package radicale-configuration-package + (default radicale)) + (config-file radicale-configuration-config-file + (default %default-radicale-config-file))) + +(define %default-radicale-config-file + (plain-file "radicale.conf" " +[auth] +type = htpasswd +htpasswd_filename = /var/lib/radicale/users +htpasswd_encryption = plain + +[server] +hosts = localhost:5232")) + +(define %radicale-accounts + (list (user-group + (name "radicale") + (system? #t)) + (user-account + (name "radicale") + (group "radicale") + (system? #t) + (comment "Radicale Daemon") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))) + +(define radicale-shepherd-service + (match-lambda + (($ package config-file) + (list (shepherd-service + (provision '(radicale)) + (documentation "Run the radicale daemon.") + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/bin/radicale") + "-C" #$config-file) + #:user "radicale" + #:group "radicale")) + (stop #~(make-kill-destructor))))))) + +(define radicale-activation + (match-lambda + (($ package config-file) + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (let ((uid (passwd:uid (getpw "radicale"))) + (gid (group:gid (getgr "radicale")))) + (mkdir-p "/var/lib/radicale/collections") + (chown "/var/lib/radicale" uid gid) + (chown "/var/lib/radicale/collections" uid gid) + (chmod "/var/lib/radicale" #o700))))))) + +(define radicale-service-type + (service-type + (name 'radicale) + (description "Run radicale, a small CalDAV and CardDAV server.") + (extensions + (list (service-extension shepherd-root-service-type radicale-shepherd-service) + (service-extension account-service-type (const %radicale-accounts)) + (service-extension activation-service-type radicale-activation))) + (default-value (radicale-configuration)))) -- cgit v1.2.3 From ad911c832178216b0121c6ecb8349d1a9d68526f Mon Sep 17 00:00:00 2001 From: Rovanion Luckey Date: Tue, 15 Dec 2020 12:33:12 +0100 Subject: doc: Running Guix Before It Is Installed: mention ./bootstrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/contributing.texi (Running Guix Before It Is Installed): Instruct user to run ./bootstrap before ./configure. Signed-off-by: Jakub Kądziołka --- doc/contributing.texi | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'doc') diff --git a/doc/contributing.texi b/doc/contributing.texi index 4195cb4105..d0ab08336a 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -166,14 +166,15 @@ actually installing them. So that you can distinguish between your ``end-user'' hat and your ``motley'' costume. To that end, all the command-line tools can be used even if you have not -run @code{make install}. To do that, you first need to have an environment -with all the dependencies available (@pxref{Building from Git}), and then -simply prefix each command with -@command{./pre-inst-env} (the @file{pre-inst-env} script lives in the -top build tree of Guix; it is generated by @command{./configure}). -As an example, here is how you would build the @code{hello} package as -defined in your working tree (this assumes @command{guix-daemon} is -already running on your system; it's OK if it's a different version): +run @code{make install}. To do that, you first need to have an +environment with all the dependencies available (@pxref{Building from +Git}), and then simply prefix each command with @command{./pre-inst-env} +(the @file{pre-inst-env} script lives in the top build tree of Guix; it +is generated by running @command{./bootstrap} followed by +@command{./configure}). As an example, here is how you would build the +@code{hello} package as defined in your working tree (this assumes +@command{guix-daemon} is already running on your system; it's OK if it's +a different version): @example $ ./pre-inst-env guix build hello -- cgit v1.2.3 From 6c3690fc572bf3231ae60743671b357ffd243017 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 4 Jan 2021 16:43:20 +0100 Subject: guix system: Add '--graph-backend'. * guix/scripts/system.scm (lookup-backend): New procedure. (export-extension-graph, export-shepherd-graph): Add #:backend parameter and honor it. (show-help, %options): Add "--graph-backend". (%default-options): Add 'graph-backend'. (process-action): Pass #:backend to 'export-extension-graph' and 'export-shepherd-graph'. * doc/guix.texi (Invoking guix system): Document '--graph-backend'. --- doc/guix.texi | 13 +++++++++---- guix/scripts/system.scm | 43 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 13 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 1081ed26a3..0f6e95a65a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21,7 +21,7 @@ @set SUBSTITUTE-URL https://@value{SUBSTITUTE-SERVER} @copying -Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès@* +Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès@* Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@* Copyright @copyright{} 2013 Nikita Karetnikov@* Copyright @copyright{} 2014, 2015, 2016 Alex Kost@* @@ -31548,10 +31548,12 @@ each other: @table @code @item extension-graph -Emit in Dot/Graphviz format to standard output the @dfn{service +Emit to standard output the @dfn{service extension graph} of the operating system defined in @var{file} (@pxref{Service Composition}, for more information on service -extensions). +extensions). By default the output is in Dot/Graphviz format, but you +can choose a different format with @option{--graph-backend}, as with +@command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}): The command: @@ -31563,11 +31565,14 @@ shows the extension relations among services. @anchor{system-shepherd-graph} @item shepherd-graph -Emit in Dot/Graphviz format to standard output the @dfn{dependency +Emit to standard output the @dfn{dependency graph} of shepherd services of the operating system defined in @var{file}. @xref{Shepherd Services}, for more information and for an example graph. +Again, the default output format is Dot/Graphviz, but you can pass +@option{--graph-backend} to select a different one. + @end table @node Invoking guix deploy diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 0dcf2b3afe..51c8cf2f76 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2016 Alex Kost ;;; Copyright © 2016, 2017, 2018 Chris Marusich ;;; Copyright © 2017, 2019 Mathieu Othacehe @@ -48,7 +48,8 @@ #:autoload (guix scripts package) (delete-generations delete-matching-generations) #:autoload (guix scripts pull) (channel-commit-hyperlink) - #:use-module (guix graph) + #:autoload (guix graph) (export-graph node-type + graph-backend-name %graph-backends) #:use-module (guix scripts graph) #:use-module (guix scripts system reconfigure) #:use-module (guix build utils) @@ -887,18 +888,28 @@ Run 'herd status' to view the list of services on your system.\n")))))) (register-root* (list output) gc-root)) (return output))))))))) -(define (export-extension-graph os port) - "Export the service extension graph of OS to PORT." +(define (lookup-backend name) ;TODO: factorize + "Return the graph backend called NAME. Raise an error if it is not found." + (or (find (lambda (backend) + (string=? (graph-backend-name backend) name)) + %graph-backends) + (leave (G_ "~a: unknown backend~%") name))) + +(define* (export-extension-graph os port + #:key (backend (lookup-backend "graphviz"))) + "Export the service extension graph of OS to PORT using BACKEND." (let* ((services (operating-system-services os)) (system (find (lambda (service) (eq? (service-kind service) system-service-type)) services))) (export-graph (list system) (current-output-port) + #:backend backend #:node-type (service-node-type services) #:reverse-edges? #t))) -(define (export-shepherd-graph os port) - "Export the graph of shepherd services of OS to PORT." +(define* (export-shepherd-graph os port + #:key (backend (lookup-backend "graphviz"))) + "Export the graph of shepherd services of OS to PORT using BACKEND." (let* ((services (operating-system-services os)) (pid1 (fold-services services #:target-type shepherd-root-service-type)) @@ -907,6 +918,7 @@ Run 'herd status' to view the list of services on your system.\n")))))) (null? (shepherd-service-requirement service))) shepherds))) (export-graph sinks (current-output-port) + #:backend backend #:node-type (shepherd-service-node-type shepherds) #:reverse-edges? #t))) @@ -1014,6 +1026,10 @@ Some ACTIONS support additional ARGS.\n")) (display (G_ " -v, --verbosity=LEVEL use the given verbosity LEVEL")) (newline) + (display (G_ " + --graph-backend=BACKEND + use BACKEND for 'extension-graphs' and 'shepherd-graph'")) + (newline) (display (G_ " -h, --help display this help and exit")) (display (G_ " @@ -1109,6 +1125,9 @@ Some ACTIONS support additional ARGS.\n")) (option '(#\r "root") #t #f (lambda (opt name arg result) (alist-cons 'gc-root arg result))) + (option '("graph-backend") #t #f + (lambda (opt name arg result) + (alist-cons 'graph-backend arg result))) %standard-build-options)) (define %default-options @@ -1128,7 +1147,8 @@ Some ACTIONS support additional ARGS.\n")) (image-size . guess) (install-bootloader? . #t) (label . #f) - (volatile-root? . #f))) + (volatile-root? . #f) + (graph-backend . "graphviz"))) (define (verbosity-level opts) "Return the verbosity level based on OPTS, the alist of parsed options." @@ -1191,6 +1211,9 @@ resulting from command-line parsing." (bootloader-configuration-target (operating-system-bootloader os))))) + (define (graph-backend) + (lookup-backend (assoc-ref opts 'graph-backend))) + (with-store store (set-build-options-from-command-line store opts) @@ -1205,9 +1228,11 @@ resulting from command-line parsing." (set-guile-for-build (default-guile)) (case action ((extension-graph) - (export-extension-graph os (current-output-port))) + (export-extension-graph os (current-output-port) + #:backend (graph-backend))) ((shepherd-graph) - (export-shepherd-graph os (current-output-port))) + (export-shepherd-graph os (current-output-port) + #:backend (graph-backend))) (else (unless (memq action '(build init)) (warn-about-old-distro #:suggested-command -- cgit v1.2.3 From 8480c65bb7e5e73345d5ca355d0a137796efa078 Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Mon, 4 Jan 2021 15:21:55 -0500 Subject: doc: Link to "Keyboard Layout" in "operating-system Reference" * doc/guix.texi (operating-system Reference): Link to the "Keyboard Layout" node. Signed-off-by: Mathieu Othacehe --- doc/guix.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 0f6e95a65a..884224fce6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13359,7 +13359,8 @@ The default label includes the kernel name and version. @item @code{keyboard-layout} (default: @code{#f}) This field specifies the keyboard layout to use in the console. It can be either @code{#f}, in which case the default keyboard layout is used (usually -US English), or a @code{} record. +US English), or a @code{} record. @xref{Keyboard Layout}, +for more information. This keyboard layout is in effect as soon as the kernel has booted. For instance, it is the keyboard layout in effect when you type a passphrase if -- cgit v1.2.3