all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Olivier Dion <olivier.dion@polymtl.ca>
To: Olivier Dion via <gwl-devel@gnu.org>
Cc: Olivier Dion <olivier.dion@polymtl.ca>
Subject: [PATCH v1 1/2] packages: Support for full Guix specification
Date: Thu, 21 Apr 2022 15:51:57 -0400	[thread overview]
Message-ID: <20220421195158.22407-1-olivier.dion@polymtl.ca> (raw)
In-Reply-To: <87wnfiuzal.fsf@laura>

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



  parent reply	other threads:[~2022-04-21 20:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 17:22 Packages specification does not work Olivier Dion via
2022-04-21 18:25 ` Olivier Dion via
2022-04-21 19:51 ` Olivier Dion [this message]
2022-04-21 19:51   ` [PATCH v1 2/2] pre-inst-env.in: Export GUIX_EXTENSIONS_PATH Olivier Dion
2022-04-29 11:42     ` Ricardo Wurmus
2022-04-21 20:10   ` [PATCH v1 1/2] packages: Support for full Guix specification Olivier Dion via
2022-04-22 18:43   ` [PATCH v2 0/2] Support full package specifications Olivier Dion
2022-04-22 18:43     ` [PATCH v2 1/2] packages: Support for full Guix specification Olivier Dion
2022-04-26 18:11       ` Ricardo Wurmus
2022-04-26 18:59         ` Olivier Dion via
2022-04-26 20:30           ` Ricardo Wurmus
2022-04-26 21:52             ` Olivier Dion via
2022-04-22 18:43     ` [PATCH v2 2/2] pre-inst-env.in: Export GUIX_EXTENSIONS_PATH Olivier Dion
2022-04-29  9:00       ` zimoun
2022-04-29 18:02     ` [PATCH v3 0/1] Support full package specifications Olivier Dion
2022-04-29 18:02       ` [PATCH v3 1/1] packages: Support for full Guix specification Olivier Dion
2022-05-22  6:43         ` Ricardo Wurmus
2022-05-22 12:33           ` Olivier Dion via
2022-05-17 20:40       ` [PATCH v3 0/1] Support full package specifications Olivier Dion via
2022-05-22 12:38       ` [PATCH v4] packages: Support for full Guix specification Olivier Dion
2022-05-23 21:02         ` Ricardo Wurmus
2022-05-23 21:45         ` [PATCH v5] " Olivier Dion
2022-06-01 13:07           ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220421195158.22407-1-olivier.dion@polymtl.ca \
    --to=olivier.dion@polymtl.ca \
    --cc=gwl-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.