gnu: janet: Respect GUIX_JANET_PATH
authorJack Hill <jackhill@jackhill.us>
Thu, 13 May 2021 05:13:08 +0000 (01:13 -0400)
committerJack Hill <jackhill@jackhill.us>
Fri, 9 Jul 2021 23:42:05 +0000 (19:42 -0400)
* gnu/packages/patches/janet-guix-janet-path.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/lisp.scm (janet)[source]: Use it
[native-search-paths]: New field.

gnu/local.mk
gnu/packages/lisp.scm
gnu/packages/patches/janet-guix-janet-path.patch [new file with mode: 0644]

index b242cd4..db2901c 100644 (file)
@@ -1270,6 +1270,7 @@ dist_patch_DATA =                                         \
   %D%/packages/patches/jamvm-2.0.0-aarch64-support.patch       \
   %D%/packages/patches/jamvm-2.0.0-disable-branch-patching.patch       \
   %D%/packages/patches/jamvm-2.0.0-opcode-guard.patch          \
+  %D%/packages/patches/janet-guix-janet-path.patch             \
   %D%/packages/patches/java-antlr4-Add-standalone-generator.patch      \
   %D%/packages/patches/java-antlr4-fix-code-too-large.java     \
   %D%/packages/patches/java-tunnelvisionlabs-antlr-code-too-large.patch        \
index b1f840a..0a624bc 100644 (file)
@@ -1066,6 +1066,8 @@ including a built-in database engine and a GUI system.")
        (file-name (git-file-name name version))
        (sha256
         (base32 "0gl0p3x0ylj4hxiwjclg1waxq8csadw60qw6pa9h5y4w1bcqffmk"))
+       (patches
+        (search-patches "janet-guix-janet-path.patch"))))
     (build-system gnu-build-system)
     (arguments
      `(#:make-flags (list
@@ -1075,6 +1077,11 @@ including a built-in database engine and a GUI system.")
        #:phases
        (modify-phases %standard-phases
          (delete 'configure))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "GUIX_JANET_PATH")
+            (separator ":")
+            (files '("lib/janet")))))
     (home-page "https://janet-lang.org/")
     (synopsis "Functional, imperative and embeddable programming language")
     (description
diff --git a/gnu/packages/patches/janet-guix-janet-path.patch b/gnu/packages/patches/janet-guix-janet-path.patch
new file mode 100644 (file)
index 0000000..5082beb
--- /dev/null
@@ -0,0 +1,37 @@
+author: Jack Hill <jackhill@jackhill.us>
+Upstream discussion: https://github.com/janet-lang/janet/discussions/695
+diff --git a/src/boot/boot.janet b/src/boot/boot.janet
+index 59e0a016..f9174916 100644
+--- a/src/boot/boot.janet
++++ b/src/boot/boot.janet
+@@ -3328,6 +3328,30 @@
+   (if-let [jp (getenv-alias "JANET_HEADERPATH")] (setdyn :headerpath jp))
+   (if-let [jprofile (getenv-alias "JANET_PROFILE")] (setdyn :profilepath jprofile))
++  # Guix customization to make Janet respect GUIX_JANET_PATH
++  # environment variable.  GUIX_JANET_PATH is a native search path
++  # added by Guix to tell Janet where to find modules install in the
++  # same profile via Guix packages.  This is done by augmenting
++  # Janet's module/paths array.
++  (def- guix-janet-path (os/getenv "GUIX_JANET_PATH"))
++
++  # The Janet standard extensions and loaders.  List copied from
++  # the calls to module/add-paths in src/boot/boot.janet.
++  (def- default-janet-loaders
++    [[":native:" :native]
++     ["/init.janet" :source]
++     [".janet" :source]
++     [".jimage" :image]])
++
++  (defn- add-guix-path [p]
++    (each [ext loader] default-janet-loaders
++      (array/push module/paths [(string p "/:all:" ext) loader check-is-dep])))
++
++  (if guix-janet-path
++    (each elem (string/split ":" guix-janet-path)
++      (add-guix-path elem)))
++  # End of Guix customization
++
+   # Flag handlers
+   (def handlers
+     {"h" (fn [&]
\ No newline at end of file