Subject: [bug#49607] [PATCH v3 1/3] gnu: idris: Use wrap-program to define IDRIS_CC

From: Attila Lendvai <[email-masked]>
Date: Thu, 28 Apr 2022 15:28:00 +0200

Idris requires a C compiler at runtime to generate executables.

* gnu/packages/idris.scm (idris) [inputs]: Add bash-minimal (for wrap-program).
[phases]: Add wrap-program phase to define IDRIS_CC, use (cc-for-target).
---

v3: i have rebased them to master, i.e. on top of the idris-1.3.4 update.

it also cleans it up a bit more (e.g. got rid of the clang-toolchain dependency).

 gnu/packages/idris.scm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/idris.scm b/gnu/packages/idris.scm
index 8f08ed3a3e..61de4883b1 100644
--- a/gnu/packages/idris.scm
+++ b/gnu/packages/idris.scm
@@ -22,6 +22,7 @@
 
 (define-module (gnu packages idris)
   #:use-module (gnu packages)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages haskell-check)
   #:use-module (gnu packages haskell-web)
   #:use-module (gnu packages haskell-xyz)
@@ -35,7 +36,8 @@ (define-module (gnu packages idris)
   #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module ((guix licenses) #:prefix license:)
-  #:use-module (guix packages))
+  #:use-module (guix packages)
+  #:use-module (guix utils))
 
 (define-public idris
   (package
@@ -56,7 +58,8 @@ (define-public idris
      (list perl ghc-cheapskate ghc-tasty ghc-tasty-golden
            ghc-tasty-rerun))
     (inputs
-     (list gmp
+     (list bash-minimal
+           gmp
            ncurses
            ghc-aeson
            ghc-annotated-wl-pprint
@@ -132,7 +135,13 @@ (define-public idris
                    (static (assoc-ref outputs "static"))
                    (filename "/lib/idris/rts/libidris_rts.a"))
                (rename-file (string-append static filename)
-                            (string-append out filename))))))))
+                            (string-append out filename)))))
+         (add-before 'check 'wrap-program
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (exe (string-append out "/bin/idris")))
+               (wrap-program exe
+                 `("IDRIS_CC" = (,',(cc-for-target))))))))))
     (native-search-paths
      (list (search-path-specification
             (variable "IDRIS_LIBRARY_PATH")
-- 
2.35.1