gwl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/2] packages: Support for full Guix specification


From: Olivier Dion
Subject: [PATCH v2 1/2] packages: Support for full Guix specification
Date: Fri, 22 Apr 2022 14:43:58 -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        | 31 +++++++++++++++++++++++--------
 gwl/processes.scm       |  2 +-
 gwl/workflows/graph.scm |  2 +-
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/gwl/packages.scm b/gwl/packages.scm
index 6fe82d4..1658e03 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) (simple-package (%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.
diff --git a/gwl/processes.scm b/gwl/processes.scm
index ce40d12..cdb0988 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]