-
I'm working on improving the Janet and jpm-installable module experience on Guix. Currently, we don't have any module packages, but this is something that I'd like change. Guix, like its cousin Nix, installs software differently than traditional operating systems. Essentially, rather than installing all packages into the same central location, each package gets its own directory hierarchy. Multiple views representing different subsets of packages can be created and used for system-wide installed software, software installed for each user, temporary development environments, etc. For this use case, I don't think setting I'm working on a proof of concept currently, and can fairly easily add entries to I have two questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Oh, I think I now see part of what I was missing: the |
Beta Was this translation helpful? Give feedback.
-
Ok, I think I've figured out that I should do my custom code in the beginning of cli-main. This is the patch that I'm going to propose we add to our Janet package in Guix: author: Jack Hill <[email protected]>
diff --git a/src/boot/boot.janet b/src/boot/boot.janet
index feb577ad..fa35cb7d 100644
--- a/src/boot/boot.janet
+++ b/src/boot/boot.janet
@@ -3347,6 +3347,26 @@
(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"))
+
+ (defn- add-guix-path [ext loader]
+ (if guix-janet-path
+ (each elem (reverse (string/split ":" guix-janet-path))
+ (array/insert module/paths 1 [(string elem "/:all:" ext) loader check-is-dep]))))
+
+ # Add the Janet standard extensions and loaders. List copied from
+ # the calls to module/add-paths in src/boot/boot.janet.
+ (add-guix-path ":native:" :native)
+ (add-guix-path "/init.janet" :source)
+ (add-guix-path ".janet" :source)
+ (add-guix-path ".jimage" :image)
+ # End of Guix customization
+
# Flag handlers
(def handlers
{"h" (fn [&] Does this seem reasonable? Can you think of a better way for Guix and Janet to play nicely together? |
Beta Was this translation helpful? Give feedback.
-
The proposed patch looks pretty good to me. However, I think guix packages should go at the end of module/paths and not take precedence over local files. The paths are tried in order, so inserting them at the end would make more sense, or at least at the same position as the
Should probably come after the preload and current loaders, though. |
Beta Was this translation helpful? Give feedback.
-
I already actually have submitted a patch for Guix and I got it to work in guix shell, guix home and guix system. Could you have a look and let me know if we can improve it using your suggestions. I mean instead of having multiple patches submitted. I got it to work using the current jpm code with a few substitutions. |
Beta Was this translation helpful? Give feedback.
The proposed patch looks pretty good to me. However, I think guix packages should go at the end of module/paths and not take precedence over local files. The paths are tried in order, so inserting them at the end would make more sense, or at least at the same position as the
:sys:
entries