guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/04: profiles: Build the man database only if 'man-db' is in the profi


From: guix-commits
Subject: 03/04: profiles: Build the man database only if 'man-db' is in the profile.
Date: Sat, 6 Nov 2021 18:19:36 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 3c1158ac4e5ef825a9b9a229a233fabd7cef334e
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Oct 26 16:01:40 2021 +0200

    profiles: Build the man database only if 'man-db' is in the profile.
    
    This allows us to skip the expensive man-db profile hook in most cases.
    
    Suggested by Liliana Marie Prikler <liliana.prikler@gmail.com>.
    
    * guix/profiles.scm (manual-database/optional): New procedure.
    (%default-profile-hooks): Use it instead of 'manual-database'.
    * doc/guix.texi (Documentation): Add footnote about 'man -k' database
    creation.
---
 doc/guix.texi     |  4 +++-
 guix/profiles.scm | 12 +++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index ea1973f..b35fb35 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36611,7 +36611,9 @@ $ info -k TLS
 @end example
 
 @noindent
-The command below searches for the same keyword in man pages:
+The command below searches for the same keyword in man
+pages@footnote{The database searched by @command{man -k} is only created
+in profiles that contain the @code{man-db} package.}:
 
 @example
 $ man -k TLS
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 9f30349..ffdd5f5 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1682,6 +1682,16 @@ the entries in MANIFEST."
                     `((type . profile-hook)
                       (hook . manual-database))))
 
+(define (manual-database/optional manifest)
+  "Return a derivation to build the manual database of MANIFEST, but only if
+MANIFEST contains the \"man-db\" package.  Otherwise, return #f."
+  ;; Building the man database (for "man -k") is expensive and rarely used.
+  ;; Build it only if the profile also contains "man-db".
+  (mlet %store-monad ((man-db (manifest-lookup-package manifest "man-db")))
+    (if man-db
+        (manual-database manifest)
+        (return #f))))
+
 (define (texlive-configuration manifest)
   "Return a derivation that builds a TeXlive configuration for the entries in
 MANIFEST."
@@ -1784,7 +1794,7 @@ MANIFEST."
   ;; 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
+        manual-database/optional
         fonts-dir-file
         ghc-package-cache-file
         ca-certificate-bundle



reply via email to

[Prev in Thread] Current Thread [Next in Thread]