aboutsummaryrefslogtreecommitdiff
path: root/guix/packages.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-06-16 23:19:16 +0200
committerLudovic Courtès <ludo@gnu.org>2021-07-11 00:49:14 +0200
commitba32f6363878165b3ca53113f6c95b8677b8537b (patch)
tree87e66d5f8bb9f828c7f062a7389b5ce415febce0 /guix/packages.scm
parentb7f1b4c1d072c6da92e20ddadb24e54da0ddd142 (diff)
downloadguix-ba32f6363878165b3ca53113f6c95b8677b8537b.tar
guix-ba32f6363878165b3ca53113f6c95b8677b8537b.tar.gz
packages: Add 'lookup-package-input' & co.
* guix/packages.scm (lookup-input, lookup-package-input) (lookup-package-native-input, lookup-package-propagated-input) (lookup-package-direct-input): New procedures. * doc/guix.texi (package Reference): Document them.
Diffstat (limited to 'guix/packages.scm')
-rw-r--r--guix/packages.scm34
1 files changed, 34 insertions, 0 deletions
diff --git a/guix/packages.scm b/guix/packages.scm
index 37814c2f63..ac5ff5a51b 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,11 @@
deprecated-package
package-field-location
+ lookup-package-input
+ lookup-package-native-input
+ lookup-package-propagated-input
+ lookup-package-direct-input
+
package-direct-sources
package-transitive-sources
package-direct-inputs
@@ -889,6 +894,35 @@ preserved, and only duplicate propagated inputs are removed."
((input rest ...)
(loop rest (cons input result) propagated first? seen)))))
+(define (lookup-input inputs name)
+ "Lookup NAME among INPUTS, an input list."
+ ;; Note: Currently INPUTS is assumed to be an input list that contains input
+ ;; labels. In the future, input labels will be gone and this procedure will
+ ;; check package names.
+ (match (assoc-ref inputs name)
+ ((obj) obj)
+ ((obj _) obj)
+ (#f #f)))
+
+(define (lookup-package-input package name)
+ "Look up NAME among PACKAGE's inputs. Return it if found, #f otherwise."
+ (lookup-input (package-inputs package) name))
+
+(define (lookup-package-native-input package name)
+ "Look up NAME among PACKAGE's native inputs. Return it if found, #f
+otherwise."
+ (lookup-input (package-native-inputs package) name))
+
+(define (lookup-package-propagated-input package name)
+ "Look up NAME among PACKAGE's propagated inputs. Return it if found, #f
+otherwise."
+ (lookup-input (package-propagated-inputs package) name))
+
+(define (lookup-package-direct-input package name)
+ "Look up NAME among PACKAGE's direct inputs. Return it if found, #f
+otherwise."
+ (lookup-input (package-direct-inputs package) name))
+
(define (package-direct-sources package)
"Return all source origins associated with PACKAGE; including origins in
PACKAGE's inputs."