[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 1/2] packages: Support for full Guix specification
From: |
Olivier Dion |
Subject: |
[PATCH v1 1/2] packages: Support for full Guix specification |
Date: |
Thu, 21 Apr 2022 15:51:57 -0400 |
Guix package specifications match:
PACKAGE [@VERSION] [:OUTPUT]
thus the following are all valid package specifications:
- "guile"
- "guile@3.0.8"
- "guile:debug"
- "guile@3.0.8:debug"
This is not currently supported by gwl. To do so, simply return in
`lookup-package` a list with `car` as the inferior's package and `cadr` as its
output.
The `simple-package` procedure can be used to remove the package's output from
the returned value of `lookup-package` which is often necessary for manipulating
the package itself and not its output.
---
gwl/packages.scm | 35 +++++++++++++++++++++++++----------
gwl/processes.scm | 2 +-
gwl/workflows/graph.scm | 2 +-
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/gwl/packages.scm b/gwl/packages.scm
index 6fe82d4..295c31c 100644
--- a/gwl/packages.scm
+++ b/gwl/packages.scm
@@ -43,6 +43,7 @@
lookup-package
valid-package?
package-name
+ simple-package
bash-minimal
build-time-guix
@@ -71,17 +72,31 @@
(set! connection (open-connection))
connection)))))
-(define (lookup-package specification)
+(define (%lookup-package name+version output)
+ (list (match (apply lookup-inferior-packages
+ (cons (current-guix) (string-split name+version #\@)))
+ ((first . rest) first)
+ (_ (raise (condition
+ (&gwl-package-error
+ (package-spec (string-append name+version output)))))))
+ output))
+
+(define* (lookup-package specification #:optional (output "out"))
(log-event 'guix (G_ "Looking up package `~a'~%") specification)
- (match (lookup-inferior-packages (current-guix) specification)
- ((first . rest) first)
- (_ (raise (condition
- (&gwl-package-error
- (package-spec specification)))))))
+ (match (string-split specification #\:)
+ ((name+version sub-drv) (%lookup-package name+version sub-drv))
+ ((name+version) (%lookup-package name+version output))))
(define (valid-package? val)
- (or (package? val)
- (inferior-package? val)))
+ (or
+ (and (list? val)
+ (valid-package? (car val))
+ (string? (cadr val)))
+ (package? val)
+ (inferior-package? val)))
+
+(define (simple-package pkg)
+ (if (list? pkg) (car pkg) pkg))
;; Just like package-full-name from (guix packages) but for inferior
;; packages.
@@ -102,11 +117,11 @@ the version. By default, DELIMITER is \"@\"."
(define bash-minimal
(mlambda ()
- (lookup-package "bash-minimal")))
+ (simple-package (lookup-package "bash-minimal"))))
(define build-time-guix
(mlambda ()
- (lookup-package "guix")))
+ (simple-package (lookup-package "guix"))))
(define default-guile
(mlambda ()
diff --git a/gwl/processes.scm b/gwl/processes.scm
index 3a05e03..02a38c6 100644
--- a/gwl/processes.scm
+++ b/gwl/processes.scm
@@ -657,7 +657,7 @@ PROCESS."
(set-search-paths (map sexp->search-path-specification
',search-paths)
(cons ,profile
- ',packages))))
+ ',(map simple-package
packages)))))
#$(if out `(setenv "out" ,out) "")
(setenv "_GWL_PROFILE" #$profile)
(use-modules (ice-9 match))
diff --git a/gwl/workflows/graph.scm b/gwl/workflows/graph.scm
index ea3fec9..bdfdb11 100644
--- a/gwl/workflows/graph.scm
+++ b/gwl/workflows/graph.scm
@@ -43,7 +43,7 @@ label=<<FONT POINT-SIZE=\"14\">~a</FONT><BR/>\
(take-color)
(string-upcase pretty-name)
(process-synopsis process)
- (match (process-packages process)
+ (match (map simple-package (process-packages process))
(() "")
(inputs (format #f "<BR/>Uses: ~{~a~^, ~}."
(map package-name inputs)))))))
--
2.35.1
- Packages specification does not work, Olivier Dion, 2022/04/21
- Re: Packages specification does not work, Olivier Dion, 2022/04/21
- [PATCH v1 1/2] packages: Support for full Guix specification,
Olivier Dion <=
- [PATCH v1 2/2] pre-inst-env.in: Export GUIX_EXTENSIONS_PATH, Olivier Dion, 2022/04/21
- Re: [PATCH v1 1/2] packages: Support for full Guix specification, Olivier Dion, 2022/04/21
- [PATCH v2 0/2] Support full package specifications, Olivier Dion, 2022/04/22
- [PATCH v2 1/2] packages: Support for full Guix specification, Olivier Dion, 2022/04/22
- Re: [PATCH v2 1/2] packages: Support for full Guix specification, Ricardo Wurmus, 2022/04/26
- Re: [PATCH v2 1/2] packages: Support for full Guix specification, Olivier Dion, 2022/04/26
- Re: [PATCH v2 1/2] packages: Support for full Guix specification, Ricardo Wurmus, 2022/04/26
- Re: [PATCH v2 1/2] packages: Support for full Guix specification, Olivier Dion, 2022/04/26
- [PATCH v2 2/2] pre-inst-env.in: Export GUIX_EXTENSIONS_PATH, Olivier Dion, 2022/04/22