From aaf9aa4824a8c30e5efc869d0e7dc34754892934 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Wed, 14 Jul 2021 13:12:50 +0200 Subject: packages: Define this-package-input and this-package-native-input. These macros are intended to be used in build phases. More precisely, (assoc-ref %build-inputs "input") can be replaced by #$(this-package-input "input") or #+(this-package-native-input "native-input") as appropriate. * guix/packages.scm (package-input, package-native-input): New (unexported) procedures. (this-package-input, this-package-native-input): New macros. Signed-off-by: Mathieu Othacehe --- guix/packages.scm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'guix/packages.scm') diff --git a/guix/packages.scm b/guix/packages.scm index dfb4c680be..d3fa72fd09 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -109,6 +109,9 @@ (define-module (guix packages) deprecated-package package-field-location + this-package-input + this-package-native-input + lookup-package-input lookup-package-native-input lookup-package-propagated-input @@ -547,6 +550,32 @@ (define (package-field-location package field) #f))) (_ #f))) +(define (package-input package name) + "Return the package input NAME of PACKAGE--i.e., an input +from the ‘inputs’ or ‘propagated-inputs’ field. Native inputs are not +considered. If this input does not exist, return #f instead." + (and=> (or (assoc-ref (package-inputs package) name) + (assoc-ref (package-propagated-inputs package) name)) + car)) + +(define (package-native-input package name) + "Return the native package input NAME of PACKAGE--i.e., an input +from the ‘native-inputs’ field. If this native input does not exist, +return #f instead." + (and=> (assoc-ref (package-native-inputs package) name) + car)) + +(define-syntax-rule (this-package-input name) + "Return the input NAME of the package being defined--i.e., an input +from the ‘inputs’ or ‘propagated-inputs’ field. Native inputs are not +considered. If this input does not exist, return #f instead." + (package-input this-package name)) + +(define-syntax-rule (this-package-native-input name) + "Return the native package input NAME of the package being defined--i.e., +an input from the ‘native-inputs’ field. If this native input does not +exist, return #f instead." + (package-native-input this-package name)) ;; Error conditions. -- cgit v1.2.3