From ee0de9945438cce41ef20e37144f41a8d40cd1ab Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Thu, 29 Aug 2019 23:02:10 +0200 Subject: services: cups: Add BrowseDNSSDSubTypes directive. * gnu/services/cups.scm (comma-separated-string-list?) (serialize-comma-separated-string-list): New variables. (cups-configuration)[browse-dns-sd-sub-types]: New field. * doc/guix.texi (Printing Services): Document it. --- doc/guix.texi | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 1998ad049b..ed74034dc6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14248,6 +14248,14 @@ longer required for quotas. Defaults to @samp{#f}. @end deftypevr +@deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types +Specifies a list of DNS-SD sub-types to advertise for each shared printer. +For example, @samp{"_cups" "_print"} will tell network clients that both +CUPS sharing and IPP Everywhere are supported. + +Defaults to @samp{"_cups"}. +@end deftypevr + @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols Specifies which protocols to use for local printer sharing. -- cgit v1.2.3 From 70186c24eee7603e1763143ba97ab6abea63f10c Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Tue, 27 Aug 2019 19:22:04 +0200 Subject: services: cups: Move SET-ENV to FILES-CONFIGURATION. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/services/cups.scm (cups-configuration): Move SET-ENV from here… (files-configuration): …to here. * doc/guix.texi (Printing Services): Adjust accordingly. --- doc/guix.texi | 12 ++++++------ gnu/services/cups.scm | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index ed74034dc6..32c98e23c6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14228,6 +14228,12 @@ programs. Defaults to @samp{"lp"}. @end deftypevr + +@deftypevr {@code{files-configuration} parameter} string set-env +Set the specified environment variable to be passed to child processes. + +Defaults to @samp{"variable value"}. +@end deftypevr @end deftypevr @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level @@ -14755,12 +14761,6 @@ the output of the @code{uname} command. @code{Full} reports @code{CUPS Defaults to @samp{Minimal}. @end deftypevr -@deftypevr {@code{cups-configuration} parameter} string set-env -Set the specified environment variable to be passed to child processes. - -Defaults to @samp{"variable value"}. -@end deftypevr - @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen Listens on the specified interfaces for encrypted connections. Valid values are of the form @var{address}:@var{port}, where @var{address} is diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm index ace7889fb6..2105df6ded 100644 --- a/gnu/services/cups.scm +++ b/gnu/services/cups.scm @@ -458,7 +458,10 @@ or state files.") (user (string "lp") "Specifies the user name or ID that is used when running external -programs.")) +programs.") + (set-env + (string "variable value") + "Set the specified environment variable to be passed to child processes.")) (define (serialize-files-configuration field-name val) #f) @@ -811,9 +814,6 @@ reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is the output of the @code{uname} command. @code{Full} reports @code{CUPS 2.0.0 (@var{uname}) IPP/2.0}.") - (set-env - (string "variable value") - "Set the specified environment variable to be passed to child processes.") (ssl-listen (multiline-string-list '()) "Listens on the specified interfaces for encrypted connections. Valid -- cgit v1.2.3 From 3774efe36ff0cd20359506064484079001984f1c Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Fri, 30 Aug 2019 17:28:24 +0200 Subject: doc: Prefer https:// over git://. * doc/guix.texi (Continuous Integration): Use https:// in fictitious URLs. --- doc/guix.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 32c98e23c6..663228f00e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21377,12 +21377,12 @@ the @code{"custom-packages"} input, which is the equivalent of (#:branch . "master") (#:no-compile? . #t)) ((#:name . "config") - (#:url . "git://git.example.org/config.git") + (#:url . "https://git.example.org/config.git") (#:load-path . ".") (#:branch . "master") (#:no-compile? . #t)) ((#:name . "custom-packages") - (#:url . "git://git.example.org/custom-packages.git") + (#:url . "https://git.example.org/custom-packages.git") (#:load-path . ".") (#:branch . "master") (#:no-compile? . #t))))))) -- cgit v1.2.3 From 7e5e39a72fbe5b8bc832d6b15a94b75c7e28e6b0 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Fri, 30 Aug 2019 17:42:51 +0200 Subject: doc: Update GIT-DOWNLOAD @example. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/guix.texi (origin Reference): Use (HTTPS, GNU-hosted) ‘hello’ package repository instead of off-line ‘shadow’ one. --- doc/guix.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 663228f00e..8469aad2b4 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5565,8 +5565,8 @@ specified in the @code{uri} field as a @code{git-reference} object; a @example (git-reference - (url "git://git.debian.org/git/pkg-shadow/shadow") - (commit "v4.1.5.1")) + (url "https://git.savannah.gnu.org/git/hello.git") + (commit "v2.10")) @end example @end table -- cgit v1.2.3 From 5a097cdd5446587511dbee049ad706366c74e5ad Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Sat, 31 Aug 2019 03:23:16 +0200 Subject: services: cups: Rename ‘retry-this-job’ to ‘retry-current-job’. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/services/cups.scm (error-policy, cups-configuration): Substitute RETRY-CURRENT-JOB for the obsolete RETRY-THIS-JOB name of this policy. * doc/guix.texi (Printing Services): Likewise. --- doc/guix.texi | 2 +- gnu/services/cups.scm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 8469aad2b4..54c7ea739e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14347,7 +14347,7 @@ Defaults to @samp{30}. Specifies what to do when an error occurs. Possible values are @code{abort-job}, which will discard the failed print job; @code{retry-job}, which will retry the job at a later time; -@code{retry-this-job}, which retries the failed job immediately; and +@code{retry-current-job}, which retries the failed job immediately; and @code{stop-printer}, which stops the printer. Defaults to @samp{stop-printer}. diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm index 2105df6ded..c3c6d2f1be 100644 --- a/gnu/services/cups.scm +++ b/gnu/services/cups.scm @@ -139,7 +139,7 @@ (define-enumerated-field-type default-encryption (Never IfRequested Required)) (define-enumerated-field-type error-policy - (abort-job retry-job retry-this-job stop-printer)) + (abort-job retry-job retry-current-job stop-printer)) (define-enumerated-field-type log-level (none emerg alert crit error warn notice info debug debug2)) (define-enumerated-field-type log-time-format @@ -554,7 +554,7 @@ typically within a few milliseconds.") (error-policy 'stop-printer) "Specifies what to do when an error occurs. Possible values are @code{abort-job}, which will discard the failed print job; @code{retry-job}, -which will retry the job at a later time; @code{retry-this-job}, which retries +which will retry the job at a later time; @code{retry-current-job}, which retries the failed job immediately; and @code{stop-printer}, which stops the printer.") (filter-limit -- cgit v1.2.3 From f91c843449b9b91290dae43632aa78c6f5ec02ce Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 1 Sep 2019 00:31:20 +0900 Subject: doc: Update the default list of files rotated by rottlog. * doc/guix.texi (Log Rotation): Add "/var/log/debug" and "/var/log/maillog" to the default value of %rotated-files. --- 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 54c7ea739e..d46dbc8394 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12626,7 +12626,8 @@ a couple of other files. @defvr {Scheme Variable} %rotated-files The list of syslog-controlled files to be rotated. By default it is: -@code{'("/var/log/messages" "/var/log/secure")}. +@code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \ +"/var/log/maillog")}. @end defvr @node Networking Services -- cgit v1.2.3 From 1719f4f1e3aba3af60b5f7e63b8db529ef777af5 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 1 Sep 2019 06:05:43 +0900 Subject: doc: Specify the files rotated by default by the rottlog service. * doc/guix.texi (Log Rotation): Replace "a couple of other files" by "/var/log/guix-daemon.log". --- doc/guix.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index d46dbc8394..031ee53295 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12620,8 +12620,8 @@ Either @code{#f} or a gexp to execute once the rotation has completed. @end deftp @defvr {Scheme Variable} %default-rotations -Specifies weekly rotation of @var{%rotated-files} and -a couple of other files. +Specifies weekly rotation of @var{%rotated-files} and of +@file{/var/log/guix-daemon.log}. @end defvr @defvr {Scheme Variable} %rotated-files -- cgit v1.2.3 From d34e9114e679666dfbf7caf577117010eca20520 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 2 Sep 2019 11:28:18 +0200 Subject: doc: Explain that "guix import" and "guix refresh" may need GnuPG. Fixes . Reported by Jesse Gibbons . * doc/guix.texi (Invoking guix import, Invoking guix refresh): Mention that GnuPG must be installed. --- doc/guix.texi | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 031ee53295..0510f57c23 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8509,8 +8509,13 @@ guix import @var{importer} @var{options}@dots{} @var{importer} specifies the source from which to import package metadata, and @var{options} specifies a package identifier and other -options specific to @var{importer}. Currently, the available -``importers'' are: +options specific to @var{importer}. + +Some of the importers rely on the ability to run the @command{gpgv} command. +For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install +gnupg} if needed. + +Currently, the available ``importers'' are: @table @code @item gnu @@ -8959,7 +8964,10 @@ update the version numbers and source tarball hashes of those package recipes (@pxref{Defining Packages}). This is achieved by downloading each package's latest source tarball and its associated OpenPGP signature, authenticating the downloaded tarball against its signature -using @command{gpg}, and finally computing its hash. When the public +using @command{gpgv}, and finally computing its hash---note that GnuPG must be +installed and in @code{$PATH}; run @code{guix install gnupg} if needed. + +When the public key used to sign the tarball is missing from the user's keyring, an attempt is made to automatically retrieve it from a public key server; when this is successful, the key is added to the user's keyring; otherwise, -- cgit v1.2.3 From 55549c7b9b778a79d3e1f3d085861ef36aabdca6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Aug 2019 00:54:15 +0200 Subject: lint: Add 'archival' checker. * guix/lint.scm (check-archival): New procedure. (%network-dependent-checkers): Add 'archival' checker. * tests/lint.scm ("archival: missing content") ("archival: content available") ("archival: missing revision") ("archival: revision available") ("archival: rate limit reached"): New tests. * doc/guix.texi (Invoking guix lint): Document it. --- doc/guix.texi | 25 +++++++++++++++ guix/lint.scm | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- tests/lint.scm | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 201 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 0510f57c23..de02ad8687 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9249,6 +9249,31 @@ Parse the @code{source} URL to determine if a tarball from GitHub is autogenerated or if it is a release tarball. Unfortunately GitHub's autogenerated tarballs are sometimes regenerated. +@item archival +@cindex Software Heritage, source code archive +@cindex archival of source code, Software Heritage +Checks whether the package's source code is archived at +@uref{https://www.softwareheritage.org, Software Heritage}. + +When the source code that is not archived comes from a version-control system +(VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a +``save'' request so that it eventually archives it. This ensures that the +source will remain available in the long term, and that Guix can fall back to +Software Heritage should the source code disappear from its original host. +The status of recent ``save'' requests can be +@uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}. + +When source code is a tarball obtained with @code{url-fetch}, simply print a +message when it is not archived. As of this writing, Software Heritage does +not allow requests to save arbitrary tarballs; we are working on ways to +ensure that non-VCS source code is also archived. + +Software Heritage +@uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the +request rate per IP address}. When the limit is reached, @command{guix lint} +prints a message and the @code{archival} checker stops doing anything until +that limit has been reset. + @item cve @cindex security vulnerabilities @cindex CVE, Common Vulnerabilities and Exposures diff --git a/guix/lint.scm b/guix/lint.scm index 254f4e2830..ba38bef806 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -44,6 +44,8 @@ #:use-module ((guix ui) #:select (texi->plain-text fill-paragraph)) #:use-module (guix gnu-maintenance) #:use-module (guix cve) + #:use-module ((guix swh) #:hide (origin?)) + #:autoload (guix git-download) (git-reference?) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 format) @@ -80,6 +82,7 @@ check-vulnerabilities check-for-updates check-formatting + check-archival lint-warning lint-warning? @@ -1033,6 +1036,93 @@ the NIST server non-fatal." '())) (#f '()))) ; cannot find newer upstream release + +(define (check-archival package) + "Check whether PACKAGE's source code is archived on Software Heritage. If +it's not, and if its source code is a VCS snapshot, then send a \"save\" +request to Software Heritage. + +Software Heritage imposes limits on the request rate per client IP address. +This checker prints a notice and stops doing anything once that limit has been +reached." + (define (response->warning url method response) + (if (request-rate-limit-reached? url method) + (list (make-warning package + (G_ "Software Heritage rate limit reached; \ +try again later") + #:field 'source)) + (list (make-warning package + (G_ "'~a' returned ~a") + (list url (response-code response)) + #:field 'source)))) + + (define skip-key (gensym "skip-archival-check")) + + (define (skip-when-limit-reached url method) + (or (not (request-rate-limit-reached? url method)) + (throw skip-key #t))) + + (parameterize ((%allow-request? skip-when-limit-reached)) + (catch #t + (lambda () + (match (and (origin? (package-source package)) + (package-source package)) + (#f ;no source + '()) + ((= origin-uri (? git-reference? reference)) + (define url + (git-reference-url reference)) + (define commit + (git-reference-commit reference)) + + (match (if (commit-id? commit) + (or (lookup-revision commit) + (lookup-origin-revision url commit)) + (lookup-origin-revision url commit)) + ((? revision? revision) + '()) + (#f + ;; Revision is missing from the archive, attempt to save it. + (catch 'swh-error + (lambda () + (save-origin (git-reference-url reference) "git") + (list (make-warning + package + ;; TRANSLATORS: "Software Heritage" is a proper noun + ;; that must remain untranslated. See + ;; . + (G_ "scheduled Software Heritage archival") + #:field 'source))) + (lambda (key url method response . _) + (cond ((= 429 (response-code response)) + (list (make-warning + package + (G_ "archival rate limit exceeded; \ +try again later") + #:field 'source))) + (else + (response->warning url method response)))))))) + ((? origin? origin) + ;; Since "save" origins are not supported for non-VCS source, all + ;; we can do is tell whether a given tarball is available or not. + (if (origin-sha256 origin) ;XXX: for ungoogled-chromium + (match (lookup-content (origin-sha256 origin) "sha256") + (#f + (list (make-warning package + (G_ "source not archived on Software \ +Heritage") + #:field 'source))) + ((? content?) + '())) + '())))) + (match-lambda* + ((key url method response) + (response->warning url method response)) + ((key . args) + (if (eq? key skip-key) + '() + (apply throw key args))))))) + ;;; ;;; Source code formatting. @@ -1237,7 +1327,11 @@ or a list thereof") (lint-checker (name 'refresh) (description "Check the package for new upstream releases") - (check check-for-updates)))) + (check check-for-updates)) + (lint-checker + (name 'archival) + (description "Ensure source code archival on Software Heritage") + (check check-archival)))) (define %all-checkers (append %local-checkers diff --git a/tests/lint.scm b/tests/lint.scm index c8b88136f4..1b92f02b85 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -35,6 +35,7 @@ #:use-module (guix packages) #:use-module (guix lint) #:use-module (guix ui) + #:use-module (guix swh) #:use-module (gnu packages) #:use-module (gnu packages glib) #:use-module (gnu packages pkg-config) @@ -47,6 +48,7 @@ #:use-module (ice-9 regex) #:use-module (ice-9 getopt-long) #:use-module (ice-9 pretty-print) + #:use-module (rnrs bytevectors) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9 gnu) #:use-module (srfi srfi-26) @@ -859,6 +861,85 @@ '() (check-formatting (dummy-package "x"))) +(test-assert "archival: missing content" + (let* ((origin (origin + (method url-fetch) + (uri "http://example.org/foo.tgz") + (sha256 (make-bytevector 32)))) + (warnings (with-http-server '((404 "Not archived.")) + (parameterize ((%swh-base-url (%local-url))) + (check-archival (dummy-package "x" + (source origin))))))) + (warning-contains? "not archived" warnings))) + +(test-equal "archival: content available" + '() + (let* ((origin (origin + (method url-fetch) + (uri "http://example.org/foo.tgz") + (sha256 (make-bytevector 32)))) + ;; https://archive.softwareheritage.org/api/1/content/ + (content "{ \"checksums\": {}, \"data_url\": \"xyz\", + \"length\": 42 }")) + (with-http-server `((200 ,content)) + (parameterize ((%swh-base-url (%local-url))) + (check-archival (dummy-package "x" (source origin))))))) + +(test-assert "archival: missing revision" + (let* ((origin (origin + (method git-fetch) + (uri (git-reference + (url "http://example.org/foo.git") + (commit "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))) + (sha256 (make-bytevector 32)))) + ;; https://archive.softwareheritage.org/api/1/origin/save/ + (save "{ \"origin_url\": \"http://example.org/foo.git\", + \"save_request_date\": \"2014-11-17T22:09:38+01:00\", + \"save_request_status\": \"accepted\", + \"save_task_status\": \"scheduled\" }") + (warnings (with-http-server `((404 "No revision.") ;lookup-revision + (404 "No origin.") ;lookup-origin + (200 ,save)) ;save-origin + (parameterize ((%swh-base-url (%local-url))) + (check-archival (dummy-package "x" (source origin))))))) + (warning-contains? "scheduled" warnings))) + +(test-equal "archival: revision available" + '() + (let* ((origin (origin + (method git-fetch) + (uri (git-reference + (url "http://example.org/foo.git") + (commit "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))) + (sha256 (make-bytevector 32)))) + ;; https://archive.softwareheritage.org/api/1/revision/ + (revision "{ \"author\": {}, \"parents\": [], + \"date\": \"2014-11-17T22:09:38+01:00\" }")) + (with-http-server `((200 ,revision)) + (parameterize ((%swh-base-url (%local-url))) + (check-archival (dummy-package "x" (source origin))))))) + +(test-assert "archival: rate limit reached" + ;; We should get a single warning stating that the rate limit was reached, + ;; and nothing more, in particular no other HTTP requests. + (let* ((origin (origin + (method url-fetch) + (uri "http://example.org/foo.tgz") + (sha256 (make-bytevector 32)))) + (too-many (build-response + #:code 429 + #:reason-phrase "Too many requests" + #:headers '((x-ratelimit-remaining . "0") + (x-ratelimit-reset . "3000000000")))) + (warnings (with-http-server `((,too-many "Rate limit reached.")) + (parameterize ((%swh-base-url (%local-url))) + (append-map (lambda (name) + (check-archival + (dummy-package name (source origin)))) + '("x" "y" "z")))))) + (string-contains (single-lint-warning-message warnings) + "rate limit reached"))) + (test-end "lint") ;; Local Variables: -- cgit v1.2.3 From 7c6ebf28db77f1a78bddf3758472b4e99afcc99e Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 3 Sep 2019 18:02:18 +0200 Subject: doc: guix deploy: Add missing record field to example. Reported by GNUtoo on #guix. * doc/guix.texi (Invoking guix deploy): Add missing "system" field to example. --- doc/guix.texi | 1 + 1 file changed, 1 insertion(+) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index de02ad8687..a078822871 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -25603,6 +25603,7 @@ evaluates to. As an example, @var{file} might contain a definition like this: (environment managed-host-environment-type) (configuration (machine-ssh-configuration (host-name "localhost") + (system "x86_64-linux") (user "alice") (identity "./id_rsa") (port 2222))))) -- cgit v1.2.3 From a44a535ebecd40c52514623a44d31d927ecca9da Mon Sep 17 00:00:00 2001 From: nixo Date: Mon, 29 Jul 2019 18:45:26 +0200 Subject: build: Add julia-build-system. * guix/build/julia-build-system.scm: New file. * guix/build-system/julia.scm: New file. * Makefile.am (MODULES): Add them. * doc/guix.texi (Build Systems): Document julia-build-system. Signed-off-by: Julien Lepiller --- Makefile.am | 2 + doc/guix.texi | 23 +++++++ guix/build-system/julia.scm | 132 +++++++++++++++++++++++++++++++++++++ guix/build/julia-build-system.scm | 135 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 292 insertions(+) create mode 100644 guix/build-system/julia.scm create mode 100644 guix/build/julia-build-system.scm (limited to 'doc') diff --git a/Makefile.am b/Makefile.am index 7b96c9473c..796e96f099 100644 --- a/Makefile.am +++ b/Makefile.am @@ -126,6 +126,7 @@ MODULES = \ guix/build-system/gnu.scm \ guix/build-system/guile.scm \ guix/build-system/haskell.scm \ + guix/build-system/julia.scm \ guix/build-system/linux-module.scm \ guix/build-system/node.scm \ guix/build-system/perl.scm \ @@ -184,6 +185,7 @@ MODULES = \ guix/build/texlive-build-system.scm \ guix/build/waf-build-system.scm \ guix/build/haskell-build-system.scm \ + guix/build/julia-build-system.scm \ guix/build/linux-module-build-system.scm \ guix/build/store-copy.scm \ guix/build/json.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index a078822871..6d6a09b36b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6034,6 +6034,29 @@ Packages built with @code{guile-build-system} must provide a Guile package in their @code{native-inputs} field. @end defvr +@defvr {Scheme Variable} julia-build-system +This variable is exported by @code{(guix build-system julia)}. It implements +the build procedure used by @uref{https://julialang.org/, julia} packages, +which essentially is similar to running @command{julia -e 'using Pkg; +Pkg.add(package)'} in an environment where @code{JULIA_LOAD_PATH} contains the +paths to all Julia package inputs. Tests are run not run. + +Julia packages require the source @code{file-name} to be the real name of the +package, correctly capitalized. + +For packages requiring shared library dependencies, you may need to write the +@file{/deps/deps.jl} file manually. It's usually a line of @code{const +variable = /gnu/store/libary.so} for each dependency, plus a void function +@code{check_deps() = nothing}. + +Some older packages that aren't using @file{Package.toml} yet, will require +this file to be created, too. The function @code{julia-create-package-toml} +helps creating the file. You need to pass the outputs and the source of the +package, it's name (the same as the @code{file-name} parameter), the package +uuid, the package version, and a list of dependencies specified by their name +and their uuid. +@end defvr + @defvr {Scheme Variable} minify-build-system This variable is exported by @code{(guix build-system minify)}. It implements a minification procedure for simple JavaScript packages. diff --git a/guix/build-system/julia.scm b/guix/build-system/julia.scm new file mode 100644 index 0000000000..50237905ec --- /dev/null +++ b/guix/build-system/julia.scm @@ -0,0 +1,132 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Nicolò Balzarotti +;;; +;;; 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 julia) + #:use-module ((guix build julia-build-system)) + #:use-module (gnu packages julia) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix packages) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (ice-9 match) + #:use-module (srfi srfi-26) + #:export (%julia-build-system-modules + julia-build + julia-build-system)) + +;; Commentary: +;; +;; Standard build procedure for Julia packages. +;; +;; Code: + +(define %julia-build-system-modules + ;; Build-side modules imported by default. + `((guix build julia-build-system) + ,@%gnu-build-system-modules)) + +(define (default-julia) + "Return the default Julia package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((julia-mod (resolve-interface '(gnu packages julia)))) + (module-ref julia-mod 'julia))) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (julia julia) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:target #:julia #:inputs #:native-inputs)) + + (and (not target) ;XXX: no cross-compilation + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (build-inputs `(("julia" ,julia) + ,@native-inputs)) + (outputs outputs) + (build julia-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define* (julia-build store name inputs + #:key source + (tests? #f) + (phases '(@ (guix build julia-build-system) + %standard-phases)) + (outputs '("out")) + (search-paths '()) + (system (%current-system)) + (guile #f) + (imported-modules %julia-build-system-modules) + (modules '((guix build julia-build-system) + (guix build utils)))) + "Build SOURCE using Julia, and with INPUTS." + (define builder + `(begin + (use-modules ,@modules) + (julia-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:system ,system + #:tests? ,tests? + #:phases ,phases + #:outputs %outputs + #:search-paths ',(map search-path-specification->sexp + search-paths) + #: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 julia-build-system + (build-system + (name 'julia) + (description "The build system for Julia packages") + (lower lower))) + +;;; julia.scm ends here diff --git a/guix/build/julia-build-system.scm b/guix/build/julia-build-system.scm new file mode 100644 index 0000000000..ff6fcf5fe3 --- /dev/null +++ b/guix/build/julia-build-system.scm @@ -0,0 +1,135 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Nicolò Balzarotti +;;; +;;; 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 julia-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:export (%standard-phases + julia-create-package-toml + julia-build)) + +;; Commentary: +;; +;; Builder-side code of the standard build procedure for Julia packages. +;; +;; Code: + +(define (invoke-julia code) + (invoke "julia" "-e" code)) + +;; subpath where we store the package content +(define %package-path "/share/julia/packages/") + +(define (generate-load-path inputs outputs) + (string-append + (string-join (map (match-lambda + ((_ . path) + (string-append path %package-path))) + ;; Restrict to inputs beginning with "julia-". + (filter (match-lambda + ((name . _) + (string-prefix? "julia-" name))) + inputs)) + ":") + (string-append ":" (assoc-ref outputs "out") %package-path) + ;; stdlib is always required to find Julia's standard libraries. + ;; usually there are other two paths in this variable: + ;; "@" and "@v#.#" + ":@stdlib")) + +(define* (install #:key source inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (package-dir (string-append out %package-path + (string-append + (strip-store-file-name source))))) + (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs)) + (mkdir-p package-dir) + (copy-recursively source package-dir)) + #t) + +;; TODO: Precompilation is working, but I don't know how to tell +;; julia to use use it. If (on rantime) we set HOME to +;; store path, julia tries to write files there (failing) +(define* (precompile #:key source inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (builddir (string-append out "/share/julia/")) + (package (strip-store-file-name source))) + (mkdir-p builddir) + (setenv "JULIA_DEPOT_PATH" builddir) + (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs)) + ;; Actual precompilation + (invoke-julia (string-append "using " package))) + #t) + +(define* (check #:key source inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (package (strip-store-file-name source)) + (builddir (string-append out "/share/julia/"))) + (setenv "JULIA_DEPOT_PATH" builddir) + (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs)) + (invoke-julia (string-append "using Pkg;Pkg.test(\"" package "\")"))) + #t) + +(define (julia-create-package-toml outputs source + name uuid version + deps) + "Some packages are not using the new Package.toml dependency specifications. +Write this file manually, so that Julia can find its dependencies." + (let ((f (open-file + (string-append + (assoc-ref outputs "out") + %package-path + (string-append + name "/Project.toml")) + "w"))) + (display (string-append + " +name = \"" name "\" +uuid = \"" uuid "\" +version = \"" version "\" +") f) + (when (not (null? deps)) + (display "[deps]\n" f) + (for-each (lambda dep + (display (string-append (car (car dep)) " = \"" (cdr (car dep)) "\"\n") + f)) + deps)) + (close-port f)) + #t) + +(define %standard-phases + (modify-phases gnu:%standard-phases + (delete 'check) ; tests must be run after installation + (replace 'install install) + (add-after 'install 'precompile precompile) + ;; (add-after 'install 'check check) + ;; TODO: In the future we could add a "system-image-generation" phase + ;; where we use PackageCompiler.jl to speed up package loading times + (delete 'configure) + (delete 'bootstrap) + (delete 'patch-usr-bin-file) + (delete 'build))) + +(define* (julia-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given Julia package, applying all of PHASES in order." + (apply gnu:gnu-build + #:inputs inputs #:phases phases + args)) -- cgit v1.2.3 From f8c143a7131d6f40f387f4cd2ad1fa78b5e2f429 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 6 Sep 2019 22:59:32 +0200 Subject: doc: Highlight Scheme syntax in the HTML output. * doc/build.scm (syntax-highlighted-html): New procedure. (html-manual): Use it. --- doc/build.scm | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/build.scm b/doc/build.scm index 7ba9f57bc9..c99bd505fd 100644 --- a/doc/build.scm +++ b/doc/build.scm @@ -34,6 +34,7 @@ (gnu packages gawk) (gnu packages gettext) (gnu packages guile) + (gnu packages guile-xyz) (gnu packages iso-codes) (gnu packages texinfo) (gnu packages tex) @@ -164,6 +165,115 @@ as well as images, OS examples, and translations." ;; Options passed to 'makeinfo --html'. '("--css-ref=https://www.gnu.org/software/gnulib/manual.css")) +(define* (syntax-highlighted-html input + #:key + (name "highlighted-syntax") + (syntax-css-url + "/static/base/css/code.css")) + "Return a derivation called NAME that processes all the HTML files in INPUT +to (1) add them a link to SYNTAX-CSS-URL, and (2) highlight the syntax of all +its
 blocks (as produced by 'makeinfo --html')."
+  (define build
+    (with-extensions (list guile-lib guile-syntax-highlight)
+      (with-imported-modules '((guix build utils))
+        #~(begin
+            (use-modules (htmlprag)
+                         (syntax-highlight)
+                         (syntax-highlight scheme)
+                         (syntax-highlight lexers)
+                         (guix build utils)
+                         (ice-9 match)
+                         (ice-9 threads))
+
+            (define entity->string
+              (match-lambda
+                ("rArr"   "⇒")
+                ("hellip" "…")
+                ("rsquo"  "’")
+                (e (pk 'unknown-entity e) (primitive-exit 2))))
+
+            (define (concatenate-snippets pieces)
+              ;; Concatenate PIECES, which contains strings and entities,
+              ;; replacing entities with their corresponding string.
+              (let loop ((pieces pieces)
+                         (strings '()))
+                (match pieces
+                  (()
+                   (string-concatenate-reverse strings))
+                  (((? string? str) . rest)
+                   (loop rest (cons str strings)))
+                  ((('*ENTITY* "additional" entity) . rest)
+                   (loop rest (cons (entity->string entity) strings)))
+                  ((('span _ lst ...) . rest)     ;for 
+                   (loop (append lst rest) strings))
+                  (something
+                   (pk 'unsupported-code-snippet something)
+                   (primitive-exit 1)))))
+
+            (define (syntax-highlight sxml)
+              ;; Recurse over SXML and syntax-highlight code snippets.
+              (match sxml
+                (('*TOP* decl body ...)
+                 `(*TOP* ,decl ,@(map syntax-highlight body)))
+                (('head things ...)
+                 `(head ,@things
+                        (link (@ (rel "stylesheet")
+                                 (type "text/css")
+                                 (href #$syntax-css-url)))))
+                (('pre ('@ ('class "lisp")) code-snippet ...)
+                 `(pre (@ (class "lisp"))
+                       ,(highlights->sxml
+                         (highlight lex-scheme
+                                    (concatenate-snippets code-snippet)))))
+                ((tag ('@ attributes ...) body ...)
+                 `(,tag (@ ,@attributes) ,@(map syntax-highlight body)))
+                ((tag body ...)
+                 `(,tag ,@(map syntax-highlight body)))
+                ((? string? str)
+                 str)))
+
+            (define (process-html file)
+              ;; Parse FILE and perform syntax highlighting for its Scheme
+              ;; snippets.  Install the result to #$output.
+              (format (current-error-port) "processing ~a...~%" file)
+              (let* ((shtml        (call-with-input-file file html->shtml))
+                     (highlighted  (syntax-highlight shtml))
+                     (base         (string-drop file (string-length #$input)))
+                     (target       (string-append #$output base)))
+                (mkdir-p (dirname target))
+                (call-with-output-file target
+                  (lambda (port)
+                    (write-shtml-as-html highlighted port)))))
+
+            (define (copy-as-is file)
+              ;; Copy FILE as is to #$output.
+              (let* ((base   (string-drop file (string-length #$input)))
+                     (target (string-append #$output base)))
+                (mkdir-p (dirname target))
+                (catch 'system-error
+                  (lambda ()
+                    (if (eq? 'symlink (stat:type (lstat file)))
+                        (symlink (readlink file) target)
+                        (link file target)))
+                  (lambda args
+                    (let ((errno (system-error-errno args)))
+                      (pk 'error-link file target (strerror errno))
+                      (primitive-exit 3))))))
+
+            ;; Install a UTF-8 locale so we can process UTF-8 files.
+            (setenv "GUIX_LOCPATH"
+                    #+(file-append glibc-utf8-locales "/lib/locale"))
+            (setlocale LC_ALL "en_US.utf8")
+
+            (n-par-for-each (parallel-job-count)
+                            (lambda (file)
+                              (if (string-suffix? ".html" file)
+                                  (process-html file)
+                                  (copy-as-is file)))
+                            (find-files #$input))))))
+
+  (computed-file name build))
+
 (define* (html-manual source #:key (languages %languages)
                       (version "0.0")
                       (manual "guix")
@@ -242,7 +352,10 @@ makeinfo OPTIONS."
                                                 "/html_node/images"))))
                     '#$languages))))
 
-  (computed-file (string-append manual "-html-manual") build))
+  (let* ((name   (string-append manual "-html-manual"))
+         (manual (computed-file name build)))
+    (syntax-highlighted-html manual
+                             #:name (string-append name "-highlighted"))))
 
 (define* (pdf-manual source #:key (languages %languages)
                      (version "0.0")
-- 
cgit v1.2.3