summaryrefslogtreecommitdiff
path: root/guix/inferior.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2021-04-24 06:43:46 +0100
committerChristopher Baines <mail@cbaines.net>2021-05-15 12:14:47 +0100
commit97d615b1761c2054561057f6b56e2a0caed13aa4 (patch)
treea2a18b43a4038b244c594c9d599f53563727a217 /guix/inferior.scm
parentb149c16371b935795c821d3df3d90fe9f741cbd7 (diff)
inferior: Support querying package replacements.
I'm looking at this to help with adding support for looking up package replacements to store in the Guix Data Service. * guix/inferior.scm (inferior-package-replacement): New procedure. * tests/inferior.scm ("inferior-package-replacement"): New test.
Diffstat (limited to 'guix/inferior.scm')
-rw-r--r--guix/inferior.scm22
1 files changed, 22 insertions, 0 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm
index eb457f81f9..7c8e478f2a 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -90,6 +90,7 @@
inferior-package-native-search-paths
inferior-package-transitive-native-search-paths
inferior-package-search-paths
+ inferior-package-replacement
inferior-package-provenance
inferior-package-derivation
@@ -462,6 +463,27 @@ package."
(define inferior-package-transitive-native-search-paths
(cut %inferior-package-search-paths <> 'package-transitive-native-search-paths))
+(define (inferior-package-replacement package)
+ "Return the replacement for PACKAGE. This will either be an inferior
+package, or #f."
+ (match (inferior-package-field
+ package
+ '(compose (match-lambda
+ ((? package? package)
+ (let ((id (object-address package)))
+ (hashv-set! %package-table id package)
+ (list id
+ (package-name package)
+ (package-version package))))
+ (#f #f))
+ package-replacement))
+ (#f #f)
+ ((id name version)
+ (inferior-package (inferior-package-inferior package)
+ name
+ version
+ id))))
+
(define (inferior-package-provenance package)
"Return a \"provenance sexp\" for PACKAGE, an inferior package. The result
is similar to the sexp returned by 'package-provenance' for regular packages."