1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 ;; This file contains machinery to build HTML and PDF copies of the manual
22 ;; that can be readily published on the web site. To do that, run:
24 ;; guix build -f build.scm
26 ;; The result is a directory hierarchy that can be used as the manual/
27 ;; sub-directory of the web site.
37 (gnu packages gettext)
39 (gnu packages guile-xyz)
40 (gnu packages iso-codes)
41 (gnu packages texinfo)
47 (@@ (guix self) file-append*))
49 (define translated-texi-manuals
50 (@@ (guix self) translate-texi-manuals))
53 (@@ (guix self) info-manual))
56 ;; The manual to build--i.e., the base name of a .texi file, such as "guix"
57 ;; or "guix-cookbook".
58 (or (getenv "GUIX_MANUAL")
62 ;; The cookbook is currently only translated into German.
63 (if (string=? %manual "guix-cookbook")
65 '("de" "en" "es" "fr" "ru" "zh_CN")))
67 (define (texinfo-manual-images source)
68 "Return a directory containing all the images used by the user manual, taken
69 from SOURCE, the root of the source tree."
71 (module-ref (resolve-interface '(gnu packages graphviz))
75 (file-append* source "doc/images"))
78 (with-imported-modules '((guix build utils))
80 (use-modules (guix build utils)
83 (define (dot->image dot-file format)
84 (invoke #+(file-append graphviz "/bin/dot")
85 "-T" format "-Gratio=.9" "-Gnodesep=.005"
86 "-Granksep=.00005" "-Nfontsize=9"
87 "-Nheight=.1" "-Nwidth=.1"
88 "-o" (string-append #$output "/"
89 (basename dot-file ".dot")
95 (for-each (lambda (dot-file)
96 (for-each (cut dot->image dot-file <>)
98 (find-files #$images "\\.dot$"))
101 (for-each (lambda (png-file)
102 (install-file png-file #$output))
103 (find-files #$images "\\.png$")))))
105 (computed-file "texinfo-manual-images" build))
107 (define* (texinfo-manual-source source #:key
109 (languages %languages)
111 "Gather all the source files of the Texinfo manuals from SOURCE--.texi file
112 as well as images, OS examples, and translations."
113 (define documentation
114 (file-append* source "doc"))
117 (file-append* source "gnu/system/examples"))
120 (with-imported-modules '((guix build utils))
122 (use-modules (guix build utils)
125 (define (make-version-texi language)
126 ;; Create the 'version.texi' file for LANGUAGE.
127 (let ((file (if (string=? language "en")
129 (string-append "version-" language ".texi"))))
130 (call-with-output-file (string-append #$output "/" file)
132 (let* ((version #$version)
133 (time (make-time time-utc 0 #$date))
134 (date (time-utc->date time)))
137 @set UPDATED-MONTH ~a
140 (date->string date "~e ~B ~Y")
141 (date->string date "~B ~Y")
142 version version))))))
144 (install-file #$(file-append documentation "/htmlxref.cnf")
147 (for-each (lambda (texi)
148 (install-file texi #$output))
149 (append (find-files #$documentation "\\.(texi|scm|json)$")
150 (find-files #$(translated-texi-manuals source)
153 ;; Create 'version.texi'.
154 (for-each make-version-texi '#$languages)
156 ;; Copy configuration templates that the manual includes.
157 (for-each (lambda (template)
160 #$output "/os-config-"
161 (basename template ".tmpl")
163 (find-files #$examples "\\.tmpl$"))
165 (symlink #$(texinfo-manual-images source)
166 (string-append #$output "/images")))))
168 (computed-file "texinfo-manual-source" build))
170 (define %web-site-url
171 ;; URL of the web site home page.
172 (or (getenv "GUIX_WEB_SITE_URL")
175 (define %makeinfo-html-options
176 ;; Options passed to 'makeinfo --html'.
177 '("--css-ref=https://www.gnu.org/software/gnulib/manual.css"
178 "-c" "EXTRA_HEAD=<meta name=\"viewport\" \
179 content=\"width=device-width, initial-scale=1\" />"))
181 (define guile-lib/htmlprag-fixed
182 ;; Guile-Lib with a hotfix for (htmlprag).
186 (substitute-keyword-arguments (package-arguments guile-lib)
187 ((#:phases phases '%standard-phases)
188 `(modify-phases ,phases
189 (add-before 'build 'fix-htmlprag
192 ;; "<body><blockquote><p>foo</p>\n</blockquote></body>",
193 ;; 'html->shtml' would mistakenly close 'blockquote' right
194 ;; before <p>. This patch removes 'p' from the
195 ;; 'parent-constraints' alist to fix that.
196 (substitute* "src/htmlprag.scm"
197 (("^[[:blank:]]*\\(p[[:blank:]]+\\. \\(body td th\\)\\).*")
200 (add-before 'check 'skip-known-failure
202 ;; XXX: The above change causes one test failure among
203 ;; the htmlprag tests.
204 (setenv "XFAIL_TESTS" "htmlprag.scm")
207 (define* (syntax-highlighted-html input
209 (name "highlighted-syntax")
211 "/static/base/css/code.css"))
212 "Return a derivation called NAME that processes all the HTML files in INPUT
213 to (1) add them a link to SYNTAX-CSS-URL, and (2) highlight the syntax of all
214 its <pre class=\"lisp\"> blocks (as produced by 'makeinfo --html')."
216 (with-extensions (list guile-lib/htmlprag-fixed guile-syntax-highlight)
217 (with-imported-modules '((guix build utils))
219 (use-modules (htmlprag)
221 (syntax-highlight scheme)
222 (syntax-highlight lexers)
230 (define (pair-open/close lst)
231 ;; Pair 'open' and 'close' tags produced by 'highlights' and
232 ;; produce nested 'paren' tags instead.
237 ((('open open) rest ...)
240 (loop rest (+ 1 level) '()))
241 (lambda (inner close rest)
243 (cons `(paren ,level ,open ,inner ,close)
245 ((('close str) rest ...)
247 (values (reverse result) str rest)
249 (format (current-error-port)
250 "warning: extra closing paren; context:~% ~y~%"
252 (loop rest 0 (cons `(close ,str) result)))))
254 (loop rest level (cons item result)))
257 (format (current-error-port)
258 "warning: missing ~a closing parens; context:~% ~y%"
259 level (reverse result)))
260 (values (reverse result) "" '())))))
262 (define (highlights->sxml* highlights anchors)
263 ;; Like 'highlights->sxml', but handle nested 'paren tags. This
264 ;; allows for paren matching highlights via appropriate CSS
265 ;; "hover" properties. When a symbol is encountered, look it up
266 ;; in ANCHORS, a vhash, and emit the corresponding href, if any.
267 (define (tag->class tag)
268 (string-append "syntax-" (symbol->string tag)))
271 ((? string? str) str)
272 (('paren level open (body ...) close)
273 `(span (@ (class ,(string-append "syntax-paren"
274 (number->string level))))
276 (span (@ (class "syntax-symbol"))
277 ,@(highlights->sxml* body anchors))
280 ;; Check whether we can emit a hyperlink for TEXT.
281 (match (vhash-assoc text anchors)
283 `(span (@ (class ,(tag->class 'symbol))) ,text))
285 `(a (@ (class ,(tag->class 'symbol)) (href ,target))
288 `(span (@ (class ,(tag->class tag))) ,text)))
291 (define entity->string
297 (e (pk 'unknown-entity e) (primitive-exit 2))))
299 (define (concatenate-snippets pieces)
300 ;; Concatenate PIECES, which contains strings and entities,
301 ;; replacing entities with their corresponding string.
302 (let loop ((pieces pieces)
306 (string-concatenate-reverse strings))
307 (((? string? str) . rest)
308 (loop rest (cons str strings)))
309 ((('*ENTITY* "additional" entity) . rest)
310 (loop rest (cons (entity->string entity) strings)))
311 ((('span _ lst ...) . rest) ;for <span class="roman">
312 (loop (append lst rest) strings))
314 (pk 'unsupported-code-snippet something)
315 (primitive-exit 1)))))
317 (define (syntax-highlight sxml anchors)
318 ;; Recurse over SXML and syntax-highlight code snippets.
319 (let loop ((sxml sxml))
321 (('*TOP* decl body ...)
322 `(*TOP* ,decl ,@(map loop body)))
325 (link (@ (rel "stylesheet")
327 (href #$syntax-css-url)))))
328 (('pre ('@ ('class "lisp")) code-snippet ...)
329 `(pre (@ (class "lisp"))
332 (highlight lex-scheme
333 (concatenate-snippets code-snippet)))
335 ((tag ('@ attributes ...) body ...)
336 `(,tag (@ ,@attributes) ,@(map loop body)))
338 `(,tag ,@(map loop body)))
342 (define (underscore-decode str)
343 ;; Decode STR, an "underscore-encoded" string as produced by
344 ;; makeinfo for indexes, such as "_0025base_002dservices" for
348 (match (string-index str #\_)
350 (string-concatenate-reverse (cons str result)))
352 (let ((char (string->number
353 (substring str (+ index 1) (+ index 5))
355 (loop (string-drop str (+ index 5))
356 (append (list (string (integer->char char))
357 (string-take str index))
360 (define (anchor-id->key id)
361 ;; Convert ID, an anchor ID such as
362 ;; "index-pam_002dlimits_002dservice" to the corresponding key,
363 ;; "pam-limits-service" in this example. Drop the suffix of
364 ;; duplicate anchor IDs like "operating_002dsystem-1".
365 (let ((id (if (any (cut string-suffix? <> id)
366 '("-1" "-2" "-3" "-4" "-5"))
367 (string-drop-right id 2)
370 (string-drop id (string-length "index-")))))
372 (define* (collect-anchors file #:optional (vhash vlist-null))
373 ;; Collect the anchors that appear in FILE, a makeinfo-generated
374 ;; file. Grab those from <dt> tags, which corresponds to
375 ;; Texinfo @deftp, @defvr, etc. Return VHASH augmented with
376 ;; more name/reference pairs.
377 (define string-or-entity?
380 (('*ENTITY* _ ...) #t)
383 (define (worthy-entry? lst)
385 ;; Scheme Variable: <strong>x</strong>
387 ;; <code>cups-configuration</code> parameter: …
388 (let loop ((lst lst))
390 (((? string-or-entity?) rest ...)
392 ((('strong _ ...) _ ...)
396 (let ((shtml (call-with-input-file file html->shtml)))
397 (let loop ((shtml shtml)
400 (('dt ('@ ('id id)) rest ...)
401 (if (and (string-prefix? "index-" id)
402 (worthy-entry? rest))
403 (vhash-cons (anchor-id->key id)
404 (string-append (basename file)
408 ((tag ('@ _ ...) body ...)
409 (fold loop vhash body))
411 (fold loop vhash body))
414 (define (process-html file anchors)
415 ;; Parse FILE and perform syntax highlighting for its Scheme
416 ;; snippets. Install the result to #$output.
417 (format (current-error-port) "processing ~a...~%" file)
418 (let* ((shtml (call-with-input-file file html->shtml))
419 (highlighted (syntax-highlight shtml anchors))
420 (base (string-drop file (string-length #$input)))
421 (target (string-append #$output base)))
422 (mkdir-p (dirname target))
423 (call-with-output-file target
425 (write-shtml-as-html highlighted port)))))
427 (define (copy-as-is file)
428 ;; Copy FILE as is to #$output.
429 (let* ((base (string-drop file (string-length #$input)))
430 (target (string-append #$output base)))
431 (mkdir-p (dirname target))
434 (if (eq? 'symlink (stat:type (lstat file)))
435 (symlink (readlink file) target)
438 (let ((errno (system-error-errno args)))
439 (pk 'error-link file target (strerror errno))
440 (primitive-exit 3))))))
442 (define (html? file stat)
443 (string-suffix? ".html" file))
445 ;; Install a UTF-8 locale so we can process UTF-8 files.
446 (setenv "GUIX_LOCPATH"
447 #+(file-append glibc-utf8-locales "/lib/locale"))
448 (setlocale LC_ALL "en_US.utf8")
450 ;; First process the mono-node 'guix.html' files.
451 (n-par-for-each (parallel-job-count)
453 (let ((anchors (collect-anchors mono)))
454 (process-html mono anchors)))
457 "^guix(-cookbook|)(\\.[a-zA-Z_-]+)?\\.html$"))
459 ;; Next process the multi-node HTML files in two phases: (1)
460 ;; collect the list of anchors, and (2) perform
461 ;; syntax-highlighting.
462 (let* ((multi (find-files #$input "^html_node$"
464 (anchors (n-par-map (parallel-job-count)
467 (fold collect-anchors vlist-null
468 (find-files multi html?))))
470 (n-par-for-each (parallel-job-count)
472 (let ((anchors (assoc-ref anchors (dirname file))))
473 (process-html file anchors)))
474 (append-map (lambda (multi)
475 (find-files multi html?))
478 ;; Last, copy non-HTML files as is.
480 (find-files #$input (negate html?)))))))
482 (computed-file name build))
484 (define* (html-manual source #:key (languages %languages)
488 (options %makeinfo-html-options))
489 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
491 (define manual-source
492 (texinfo-manual-source source
494 #:languages languages
498 (texinfo-manual-images source))
501 (with-imported-modules '((guix build utils))
503 (use-modules (guix build utils)
506 (define (normalize language)
507 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
508 (string-map (match-lambda
511 (string-downcase language)))
513 (define (language->texi-file-name language)
514 (if (string=? language "en")
515 (string-append #$manual-source "/"
517 (string-append #$manual-source "/"
518 #$manual "." language ".texi")))
520 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
521 (setenv "GUIX_LOCPATH"
522 #+(file-append glibc-utf8-locales "/lib/locale"))
523 (setenv "LC_ALL" "en_US.utf8")
525 (setvbuf (current-output-port) 'line)
526 (setvbuf (current-error-port) 'line)
528 ;; 'makeinfo' looks for "htmlxref.cnf" in the current directory, so
529 ;; copy it right here.
530 (copy-file (string-append #$manual-source "/htmlxref.cnf")
533 (for-each (lambda (language)
534 (let* ((texi (language->texi-file-name language))
536 "-c" ,(string-append "TOP_NODE_UP_URL=/manual/"
540 (format #t "building HTML manual for language '~a'...~%"
542 (mkdir-p (string-append #$output "/"
543 (normalize language)))
544 (setenv "LANGUAGE" language)
545 (apply invoke #$(file-append texinfo "/bin/makeinfo")
546 "-o" (string-append #$output "/"
550 (apply invoke #$(file-append texinfo "/bin/makeinfo")
553 (string-append #$output "/"
556 (if (string=? language "en")
558 (string-append "." language))
562 ;; Make sure images are available.
564 (string-append #$output "/" (normalize language)
567 (string-append #$output "/" (normalize language)
568 "/html_node/images"))))
569 (filter (compose file-exists? language->texi-file-name)
572 (let* ((name (string-append manual "-html-manual"))
573 (manual (computed-file name build)))
574 (syntax-highlighted-html manual
575 #:name (string-append name "-highlighted"))))
577 (define* (pdf-manual source #:key (languages %languages)
582 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
584 (define manual-source
585 (texinfo-manual-source source
587 #:languages languages
590 ;; FIXME: This union works, except for the table of contents of non-English
591 ;; manuals, which contains escape sequences like "^^ca^^fe" instead of
595 ;; (texlive-union (list texlive-tex-texinfo
596 ;; texlive-generic-epsf
597 ;; texlive-fonts-ec)))
600 (with-imported-modules '((guix build utils))
602 (use-modules (guix build utils)
606 (define (normalize language) ;XXX: deduplicate
607 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
608 (string-map (match-lambda
611 (string-downcase language)))
613 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
614 (setenv "GUIX_LOCPATH"
615 #+(file-append glibc-utf8-locales "/lib/locale"))
616 (setenv "LC_ALL" "en_US.utf8")
618 (string-append #+(file-append texlive "/bin") ":"
619 #+(file-append texinfo "/bin") ":"
621 ;; Below are command-line tools needed by
622 ;; 'texi2dvi' and friends.
623 #+(file-append sed "/bin") ":"
624 #+(file-append grep "/bin") ":"
625 #+(file-append coreutils "/bin") ":"
626 #+(file-append gawk "/bin") ":"
627 #+(file-append tar "/bin") ":"
628 #+(file-append diffutils "/bin")))
630 (setvbuf (current-output-port) 'line)
631 (setvbuf (current-error-port) 'line)
633 (setenv "HOME" (getcwd)) ;for kpathsea/mktextfm
635 ;; 'SOURCE_DATE_EPOCH' is honored by pdftex.
636 (setenv "SOURCE_DATE_EPOCH" "1")
638 (for-each (lambda (language)
639 (let ((opts `("--pdf"
642 ,(if (string=? language "en")
643 (string-append #$manual-source "/"
645 (string-append #$manual-source "/"
646 #$manual "." language ".texi")))))
647 (format #t "building PDF manual for language '~a'...~%"
649 (mkdir-p (string-append #$output "/"
650 (normalize language)))
651 (setenv "LANGUAGE" language)
654 ;; FIXME: Unfortunately building PDFs for non-Latin
655 ;; alphabets doesn't work:
656 ;; <https://lists.gnu.org/archive/html/help-texinfo/2012-01/msg00014.html>.
657 (guard (c ((invoke-error? c)
658 (format (current-error-port)
659 "~%~%Failed to produce \
660 PDF for language '~a'!~%~%"
662 (apply invoke #$(file-append texinfo "/bin/makeinfo")
664 (string-append #$output "/"
667 (if (string=? language "en")
675 (computed-file (string-append manual "-pdf-manual") build))
677 (define (guix-manual-text-domain source languages)
678 "Return the PO files for LANGUAGES of the 'guix-manual' text domain taken
681 (file-append* source "/po/doc"))
684 (with-imported-modules '((guix build utils))
686 (use-modules (guix build utils))
689 (for-each (lambda (language)
691 (string-append #$output "/" language
695 (invoke #+(file-append gnu-gettext "/bin/msgfmt")
697 (string-append directory "/guix-manual.mo")
698 (string-append #$po-directory "/guix-manual."
700 '#$(delete "en" languages)))))
702 (computed-file "guix-manual-po" build))
704 (define* (html-manual-indexes source
705 #:key (languages %languages)
708 (title (if (string=? "guix" manual)
709 "GNU Guix Reference Manual"
710 "GNU Guix Cookbook"))
713 (with-extensions (list guile-json-3)
714 (with-imported-modules '((guix build utils))
716 (use-modules (guix build utils)
724 (define (normalize language) ;XXX: deduplicate
725 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
726 (string-map (match-lambda
729 (string-downcase language)))
731 (define-syntax-rule (with-language language exp ...)
732 (let ((lang (getenv "LANGUAGE")))
735 (setenv "LANGUAGE" language)
736 (setlocale LC_MESSAGES))
740 (setenv "LANGUAGE" lang)
741 (unsetenv "LANGUAGE"))
742 (setlocale LC_MESSAGES)))))
744 ;; (put 'with-language 'scheme-indent-function 1)
745 (define* (translate str language
746 #:key (domain "guix-manual"))
749 (bindtextdomain "guix-manual"
750 #+(guix-manual-text-domain
753 (bindtextdomain "iso_639-3" ;language names
754 #+(file-append iso-codes
756 (write (gettext ,str ,domain))))
758 (with-language language
759 ;; Since the 'gettext' function caches msgid translations,
760 ;; regardless of $LANGUAGE, we have to spawn a new process each
761 ;; time we want to translate to a different language. Bah!
762 (let* ((pipe (open-pipe* OPEN_READ
763 #+(file-append guile-2.2
765 "-c" (object->string exp)))
770 (define (seconds->string seconds language)
771 (let* ((time (make-time time-utc 0 seconds))
772 (date (time-utc->date time)))
773 (with-language language (date->string date "~e ~B ~Y"))))
775 (define (guix-url path)
776 (string-append #$%web-site-url path))
778 (define (sxml-index language title body)
779 ;; FIXME: Avoid duplicating styling info from guix-artwork.git.
780 `(html (@ (lang ,language))
782 (title ,(string-append title " — GNU Guix"))
783 (meta (@ (charset "UTF-8")))
784 (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
786 (link (@ (rel "prefetch") (href ,(guix-url "menu/index.html"))))
788 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/elements.css"))))
789 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/common.css"))))
790 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/messages.css"))))
791 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/navbar.css"))))
792 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/breadcrumbs.css"))))
793 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/buttons.css"))))
794 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/footer.css"))))
796 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/page.css"))))
797 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/post.css")))))
799 (header (@ (class "navbar"))
800 (h1 (a (@ (class "branding")
801 (href #$%web-site-url)))
802 (span (@ (class "a11y-offset"))
804 (nav (@ (class "menu"))))
805 (nav (@ (class "breadcrumbs"))
806 (a (@ (class "crumb")
807 (href #$%web-site-url))
812 (define (language-index language)
814 (translate #$title language))
820 (@ (class "page centered-block limit-width"))
822 (p (@ (class "post-metadata centered-text"))
824 ,(seconds->string #$date language))
828 (li (a (@ (href "html_node"))
829 "HTML, with one page per node"))
833 (if (string=? language
839 "HTML, entirely on one page"))
840 ,@(if (member language '("ru" "zh_CN"))
842 `((li (a (@ (href ,(string-append
844 (if (string=? language "en")
851 (define %iso639-languages
853 (assoc-ref (call-with-input-file
854 #+(file-append iso-codes
855 "/share/iso-codes/json/iso_639-3.json")
859 (define (language-code->name code)
860 "Return the full name of a language from its ISO-639-3 code."
861 (let ((code (match (string-index code #\_)
863 (index (string-take code index)))))
864 (any (lambda (language)
865 (and (string=? (or (assoc-ref language "alpha_2")
866 (assoc-ref language "alpha_3"))
868 (assoc-ref language "name")))
871 (define (top-level-index languages)
872 (define title #$title)
877 (@ (class "page centered-block limit-width"))
880 "This document is available in the following
883 ,@(map (lambda (language)
884 `(li (a (@ (href ,(normalize language)))
886 (language-code->name language)
888 #:domain "iso_639-3"))))
891 (define (write-html file sxml)
892 (call-with-output-file file
894 (display "<!DOCTYPE html>\n" port)
895 (sxml->xml sxml port))))
897 (setenv "GUIX_LOCPATH"
898 #+(file-append glibc-utf8-locales "/lib/locale"))
899 (setenv "LC_ALL" "en_US.utf8")
900 (setlocale LC_ALL "en_US.utf8")
902 (for-each (lambda (language)
904 (string-append #$output "/"
905 (normalize language)))
908 (write-html (string-append directory "/index.html")
909 (language-index language)))
912 (write-html (string-append #$output "/index.html")
913 (top-level-index '#$languages))))))
915 (computed-file "html-indexes" build))
917 (define* (pdf+html-manual source
918 #:key (languages %languages)
920 (date (time-second (current-time time-utc)))
922 "Return the union of the HTML and PDF manuals, as well as the indexes."
923 (directory-union (string-append manual "-manual")
927 #:languages languages
930 (list html-manual-indexes
931 html-manual pdf-manual))
934 (define (latest-commit+date directory)
935 "Return two values: the last commit ID (a hex string) for DIRECTORY, and its
936 commit date (an integer)."
937 (let* ((repository (repository-open directory))
938 (head (repository-head repository))
939 (oid (reference-target head))
940 (commit (commit-lookup repository oid)))
941 ;; TODO: Use (git describe) when it's widely available.
942 (values (oid->string oid) (commit-time commit))))
945 (let* ((root (canonicalize-path
946 (string-append (current-source-directory) "/..")))
947 (commit date (latest-commit+date root)))
948 (format (current-error-port)
949 "building manual from work tree around commit ~a, ~a~%"
951 (let* ((time (make-time time-utc 0 date))
952 (date (time-utc->date time)))
953 (date->string date "~e ~B ~Y")))
954 (pdf+html-manual (local-file root "guix" #:recursive? #t
955 #:select? (git-predicate root))
956 #:version (or (getenv "GUIX_MANUAL_VERSION")
957 (string-take commit 7))