diff --git a/guix/profiles.scm b/guix/profiles.scm index 795c9447f..f565f358b 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2016 Ricardo Wurmus ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2017 Huang Ying +;;; Copyright © 2017 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -946,10 +947,73 @@ files for the fonts of the @var{manifest} entries." #:local-build? #t #:substitutable? #f)) +(define (manual-database manifest) + (define man-db ;lazy reference + (module-ref (resolve-interface '(gnu packages man)) 'man-db)) + + (define build + #~(begin + (use-modules (guix build utils) + (srfi srfi-1)) + + (define entries + (filter-map (lambda (directory) + (let ((man (string-append directory "/share/man"))) + (and (directory-exists? man) + man))) + '#$(manifest-inputs manifest))) + + (define manpages-collection-dir + (string-append (getenv "PWD") "/manpages-collection")) + + (define man-directory + (string-append #$output "/share/man")) + + (define (populate-manpages-collection-dir entries) + (let ((manpages (append-map find-files entries))) + (for-each (lambda (manpage) + (let* ((dest-file (string-append + manpages-collection-dir "/" + (strip-store-file-name manpage)))) + (mkdir-p (dirname dest-file)) + (catch 'system-error + (lambda () + (symlink manpage dest-file)) + (lambda args + ;; Different packages may contain the same + ;; manpage. Simply ignore the symlink error. + #t)))) + manpages))) + + (mkdir-p manpages-collection-dir) + (populate-manpages-collection-dir entries) + + ;; Create a mandb config file which contains a custom made + ;; manpath. The associated catpath is the location where the database + ;; gets generated. + (copy-file #+(file-append man-db "/etc/man_db.conf") + "man_db.conf") + + (substitute* "man_db.conf" + (("MANDB_MAP\\>.*$") + (string-append "MANDB_MAP " manpages-collection-dir " " + man-directory "\n"))) + + (mkdir-p man-directory) + (setenv "MANPATH" (string-join entries ":")) + (zero? (system* #+(file-append man-db "/bin/mandb") + "--quiet" "--create" + "-C" "man_db.conf")))) + + (gexp->derivation "manual-database" build + #:modules '((guix build utils)) + #:local-build? #t)) + (define %default-profile-hooks ;; This is the list of derivation-returning procedures that are called by ;; default when making a non-empty profile. (list info-dir-file + manual-database fonts-dir-file ghc-package-cache-file ca-certificate-bundle