[bug#75394,v14,2/2] gnu: Improve user-experience for jpm.

Message ID 68d09c78846a198ba4499f89f53e4b3782208c9d.1736126524.git.suhail@bayesians.ca
State New
Headers
Series Add jpm. |

Commit Message

Suhail Singh Oct. 8, 2024, 3:22 a.m. UTC
  * gnu/packages/lisp.scm (jpm): Ensure jpm respects JANET_HEADERPATH and
JANET_LIBPATH if set by user.  Ensure gcc/g++ is able to find header files and
compilation-related utilities.

Change-Id: Ic7218dbd10e6fabddded50894b82492de8cabc88
---
 gnu/packages/lisp.scm | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
  

Comments

jgart Jan. 6, 2025, 2:14 a.m. UTC | #1
Thanks! applied.

Should we add janet specific documentation in a follow up ticket somewhere?
  
Suhail Singh Jan. 7, 2025, 1:56 a.m. UTC | #2
jgart <jgart@dismail.de> writes:

> Should we add janet specific documentation

As in the "docs" target in the janet Makefile?
  
jgart Jan. 7, 2025, 2:51 a.m. UTC | #3
> 
> As in the "docs" target in the janet Makefile?
> 
I mean in the info manual for GNU Guix.

Do you intend to contribute a janet-build-system after this? In that case, then you can document any special instructions for using Guix with janet.

all best,

jgart
  
Suhail Singh Jan. 7, 2025, 3:09 a.m. UTC | #4
"jgart" <jgart@dismail.de> writes:

> Do you intend to contribute a janet-build-system after this?

Not being a janet user, likely not any time soon.  I wasn't even
intending to contribute jpm, I was simply helping review Omar's
submission.  Omar had, at one point however, mentioned a
janet-build-system [1].

> In that case, then you can document any special instructions for using
> Guix with janet.

I do agree that that would be helpful.

[1]: <https://issues.guix.gnu.org/72925#12>
  
Omar Bassam Jan. 7, 2025, 7:15 a.m. UTC | #5
Suhail Singh <suhailsingh247@gmail.com> writes:

> "jgart" <jgart@dismail.de> writes:
>
>> Do you intend to contribute a janet-build-system after this?
>
> Not being a janet user, likely not any time soon.  I wasn't even
> intending to contribute jpm, I was simply helping review Omar's
> submission.  Omar had, at one point however, mentioned a
> janet-build-system [1].
>

Yes, Thanks Suhail, your reviews helped me alot. This was my first
contribution to guix and I learned alot from it.

I would like to contribute more to guix and would like to take building
a janet-build-system as a start. I would appreciate any guidance or
recommendations on where to start to learn about building a custom build
system.

>> In that case, then you can document any special instructions for using
>> Guix with janet.
>
> I do agree that that would be helpful.
>

I am not sure where should such document be added?

> [1]: <https://issues.guix.gnu.org/72925#12>

Many Thanks to all,
Omar Bassam
  
Suhail Singh Jan. 8, 2025, 3:30 p.m. UTC | #6
Omar Bassam <omar.bassam88@gmail.com> writes:

> Yes, Thanks Suhail, your reviews helped me alot.

You're welcome :)

> I would like to contribute more to guix and would like to take building
> a janet-build-system as a start. I would appreciate any guidance or
> recommendations on where to start to learn about building a custom build
> system.

I don't have any specific guidance other than to look at existing build
system definitions.  Perhaps jgart has some thoughts?

>>> In that case, then you can document any special instructions for using
>>> Guix with janet.
>>
>> I do agree that that would be helpful.
>>
>
> I am not sure where should such document be added?

I am no authority, but perhaps the Cookbook?  Jgart, thoughts?
  

Patch

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index f99ad68828..eb3063d3d9 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -30,6 +30,7 @@ 
 ;;; Copyright © 2024 bigbug <bigbookofbug@proton.me>
 ;;; Copyright © 2024 Ashish SHUKLA <ashish.is@lostca.se>
 ;;; Copyright © 2024 Omar Bassam <omar.bassam88@gmail.com>
+;;; Copyright © 2024 Suhail Singh <suhail@bayesians.ca>
 ;;; Copyright © 2024 David Pflug <david@pflug.io>
 ;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
 ;;;
@@ -965,22 +966,39 @@  (define-public jpm
                        (setenv "PREFIX"
                                #$output)))
                    (replace 'install
-                     (lambda _
+                     (lambda* (#:key inputs #:allow-other-keys)
                        (for-each (lambda (dir)
                                    (mkdir-p (string-append #$output "/" dir)))
                                  '("lib/janet/jpm" "share/man/man1"))
                        (invoke "janet" "bootstrap.janet"
                                "configs/linux_config.janet")
-                       (wrap-program (string-append #$output "/bin/jpm")
-                         `("JANET_HEADERPATH" ":" =
-                           (,(string-append #$janet "/include/janet")))
-                         `("JANET_LIBPATH" ":" =
-                           (,(string-append #$janet "/lib")))))))))
+                       (let ((gcc-toolchain (assoc-ref inputs "gcc-toolchain"))
+                             (core-min (assoc-ref inputs "coreutils-minimal")))
+                         (wrap-program (string-append #$output "/bin/jpm")
+                           `("JANET_HEADERPATH" ":" prefix
+                             (,(string-append #$janet "/include/janet")))
+                           `("JANET_LIBPATH" ":" prefix
+                             (,(string-append #$janet "/lib")))
+                           `("C_INCLUDE_PATH" ":" prefix
+                             (,(string-append gcc-toolchain "/include")))
+                           `("CPLUS_INCLUDE_PATH" ":" prefix
+                             (,(string-append gcc-toolchain "/include/c++")
+                              ,(string-append gcc-toolchain "/include")))
+                           `("LIBRARY_PATH" ":" prefix
+                             (,(string-append gcc-toolchain "/lib")
+                              ,(string-append gcc-toolchain "/lib64")))
+                           `("PATH" ":" prefix
+                             (,(string-append gcc-toolchain "/bin")
+                              ,(string-append core-min "/bin"))))))))))
     (inputs (list bash-minimal
                   coreutils-minimal
                   curl
                   gcc
-                  git-minimal/pinned))
+                  git-minimal/pinned
+                  ;; Lazily resolve the gcc-toolchain to avoid a circular
+                  ;; dependency.
+                  (module-ref (resolve-interface '(gnu packages commencement))
+                              'gcc-toolchain)))
     (propagated-inputs (list janet))
     (native-search-paths
      (list $SSL_CERT_DIR $SSL_CERT_FILE))