diff mbox series

[bug#55030,05/30] build-system/elm: Add implicit Elm inputs.

Message ID 20220419233214.275789-5-philip@philipmcgrath.com
State New
Headers show
Series gnu: elm: Update to 0.19.1. Add build system & importer. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Philip McGrath April 19, 2022, 11:31 p.m. UTC
* guix/build-system/elm.scm (default-elm-core): New variable.
(default-elm-json): Likewise
(lower): Use them as implicit inputs when applicable.
---
 guix/build-system/elm.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/guix/build-system/elm.scm b/guix/build-system/elm.scm
index bf77df6519..046e6e0a1f 100644
--- a/guix/build-system/elm.scm
+++ b/guix/build-system/elm.scm
@@ -75,6 +75,18 @@  (define (default-elm)
   (let ((elm (resolve-interface '(gnu packages elm))))
     (module-ref elm 'elm)))
 
+(define (default-elm-core)
+  "Return the default elm-core package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((elm (resolve-interface '(gnu packages elm))))
+    (module-ref elm 'elm-core)))
+
+(define (default-elm-json)
+  "Return the default elm-json package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((elm (resolve-interface '(gnu packages elm))))
+    (module-ref elm 'elm-json)))
+
 (define* (lower name
                 #:key source inputs native-inputs outputs system target
                 (implicit-elm-package-inputs? #t)
@@ -99,6 +111,26 @@  (define private-keywords
                '())
          ,@inputs
          ("elm" ,elm)
+         ,@(cond
+            (implicit-elm-package-inputs?
+             ;; These are needed for elm-build-system even if not actually
+             ;; needed by the package being built.  But "elm/json" is often
+             ;; present in practice, and "elm/core" always is: only add the
+             ;; default packages if no suitable inputs have been given explicitly.
+             (filter-map (match-lambda
+                           ((name get-default)
+                            (cond
+                             ((find (match-lambda
+                                      ((_ pkg . _)
+                                       (equal? name (package-upstream-name pkg))))
+                                    inputs)
+                              #f)
+                             (else
+                              `(,name ,(get-default))))))
+                         `(("elm/core" ,default-elm-core)
+                           ("elm/json" ,default-elm-json))))
+            (else
+             '()))
          ;; TODO: probably don't need most of (standard-packages)
          ,@(standard-packages)))
       (outputs outputs)