summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorArun Isaac <arunisaac@systemreboot.net>2020-03-07 19:01:15 +0530
committerGuix Patches Tester <>2020-03-07 13:33:13 +0000
commitc32a5b44aadb89b818d4a7c317443b376afdd22f (patch)
tree5c87609441da51a389514ef0eaa1ad7cd5a1c2b3 /guix
parentdeb2ae4e3ba107ece5c695994ccbb3ff8dff43d8 (diff)
downloadguix-patches-c32a5b44aadb89b818d4a7c317443b376afdd22f.tar
guix-patches-c32a5b44aadb89b818d4a7c317443b376afdd22f.tar.gz
gnu: Generate Xapian package search index.
* guix/ui.scm: Export %package-metrics. * gnu/packages.scm (%package-search-index): New variable. (generate-package-search-index): New function. * guix/channels.scm (package-search-index): New function. (%channel-profile-hooks): Add package-search-index.
Diffstat (limited to 'guix')
-rw-r--r--guix/channels.scm34
-rw-r--r--guix/ui.scm2
2 files changed, 35 insertions, 1 deletions
diff --git a/guix/channels.scm b/guix/channels.scm
index f0261dc2da..c70c70938c 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -581,9 +582,40 @@ be used as a profile hook."
(hook . package-cache))
#:local-build? #t)))
+(define (package-search-index manifest)
+ "Build a package search index for the instance in MANIFEST. This is meant
+to be used as a profile hook."
+ (mlet %store-monad ((profile (profile-derivation manifest
+ #:hooks '())))
+
+ (define build
+ #~(begin
+ (use-modules (gnu packages))
+
+ (if (defined? 'generate-package-search-index)
+ (begin
+ ;; Delegate package search index generation to the inferior.
+ (format (current-error-port)
+ "Generating package search index for '~a'...~%"
+ #$profile)
+ (generate-package-search-index #$output))
+ (mkdir #$output))))
+
+ (gexp->derivation-in-inferior "guix-package-search-index" build
+ profile
+
+ ;; If the Guix in PROFILE is too old and
+ ;; lacks 'guix repl', don't build the cache
+ ;; instead of failing.
+ #:silent-failure? #t
+
+ #:properties '((type . profile-hook)
+ (hook . package-search-index))
+ #:local-build? #t)))
+
(define %channel-profile-hooks
;; The default channel profile hooks.
- (cons package-cache-file %default-profile-hooks))
+ (cons* package-cache-file package-search-index %default-profile-hooks))
(define (channel-instances->derivation instances)
"Return the derivation of the profile containing INSTANCES, a list of
diff --git a/guix/ui.scm b/guix/ui.scm
index fbe2b70485..3bc82111a5 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2019 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -120,6 +121,7 @@
relevance
package-relevance
display-search-results
+ %package-metrics
with-profile-lock
string->generations