* SCSH libraries search path @ 2022-10-31 7:18 Tom Willemse 2022-11-06 10:13 ` Efraim Flashner 0 siblings, 1 reply; 6+ messages in thread From: Tom Willemse @ 2022-10-31 7:18 UTC (permalink / raw) To: help-guix Hey Guix \o/ I've been wanting to package one of my little scripts in Guix Home and it uses a little library I wrote for SCSH. I've been looking at how Search Paths work and I'm having trouble figuring out how to make this work. Search paths seem easy enough generally, I was able to add a simple addition to my configuration by just adding this to the scsh package definition: (native-search-paths (list (search-path-specification (variable "SCSH_LIB_DIRS") (files '("share/scsh/site"))))) This successfully adds something along the lines of the following to my profile when I package my library: export SCSH_LIB_DIRS="${GUIX_PROFILE:-/gnu/store/ib05wwxl1p1b5avihw7fhvphxjhq3y97-profile}/share/scsh/site${SCSH_LIB_DIRS:+:}$SCSH_LIB_DIRS" The only problem here is that the SCSH_LIB_DIRS needs to be a space-separated list of strings instead of the usualy colon-separated list of strings. With the value `#f' denoting where to put the compiled default lib dir. For example in my manual (pre-Guix Home) configuration I have this: export SCSH_LIB_DIRS="#f \"${HOME}/usr/share/scsh/\"" To add `~/usr/share/scsh' to the places where SCSH looks for libraries (or packages as I guess scheme48 and scsh call them?). Unfortunately I can't remember how I found out about `SCSH_LIB_DIRS' and I can't find any reference to it in the manual at the moment. I looked at the `<search-path-specification>', `evaluate-search-paths', and `environment-variable-definition' source, but I think there need to be some changes made in `search-paths.scm' for this to be supported? I can't do it in my own configuration? If there is a way to do this already I would really appreciate a hint as how to do it, otherwise I'll have to see if I can add this support there, if nobody objects. I will probably need some help with this in that case. In case it helps, here is my little script and the library it uses: https://code.ryuslash.org/util/tom/mpd-random-albums/tree/ apologies for the messy UI, I'm still working on updating my CGit stylesheets and as you can probably also tell I'm not a designer. Hopefully this all makes sense :) Thanks for your time! Cheers, Tom ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: SCSH libraries search path 2022-10-31 7:18 SCSH libraries search path Tom Willemse @ 2022-11-06 10:13 ` Efraim Flashner 2022-11-14 0:49 ` Tom Willemse 0 siblings, 1 reply; 6+ messages in thread From: Efraim Flashner @ 2022-11-06 10:13 UTC (permalink / raw) To: Tom Willemse; +Cc: help-guix [-- Attachment #1: Type: text/plain, Size: 2900 bytes --] On Mon, Oct 31, 2022 at 12:18:50AM -0700, Tom Willemse wrote: > Hey Guix \o/ > > I've been wanting to package one of my little scripts in Guix Home and > it uses a little library I wrote for SCSH. I've been looking at how > Search Paths work and I'm having trouble figuring out how to make this > work. > > Search paths seem easy enough generally, I was able to add a simple > addition to my configuration by just adding this to the scsh package > definition: > > (native-search-paths > (list (search-path-specification > (variable "SCSH_LIB_DIRS") > (files '("share/scsh/site"))))) Try adding the 'separator' field, so it would look like this: (native-search-paths (list (search-path-specification (variable "SCSH_LIB_DIRS") (separator " ") (files '("share/scsh/site"))))) > This successfully adds something along the lines of the following to my > profile when I package my library: > > export SCSH_LIB_DIRS="${GUIX_PROFILE:-/gnu/store/ib05wwxl1p1b5avihw7fhvphxjhq3y97-profile}/share/scsh/site${SCSH_LIB_DIRS:+:}$SCSH_LIB_DIRS" > > The only problem here is that the SCSH_LIB_DIRS needs to be a space-separated > list of strings instead of the usualy colon-separated list of strings. > With the value `#f' denoting where to put the compiled default lib dir. > > For example in my manual (pre-Guix Home) configuration I have this: > > export SCSH_LIB_DIRS="#f \"${HOME}/usr/share/scsh/\"" > > To add `~/usr/share/scsh' to the places where SCSH looks for libraries > (or packages as I guess scheme48 and scsh call them?). > > Unfortunately I can't remember how I found out about `SCSH_LIB_DIRS' and > I can't find any reference to it in the manual at the moment. > > I looked at the `<search-path-specification>', `evaluate-search-paths', > and `environment-variable-definition' source, but I think there need to > be some changes made in `search-paths.scm' for this to be supported? I > can't do it in my own configuration? If there is a way to do this > already I would really appreciate a hint as how to do it, otherwise I'll > have to see if I can add this support there, if nobody objects. I will > probably need some help with this in that case. > > In case it helps, here is my little script and the library it uses: > https://code.ryuslash.org/util/tom/mpd-random-albums/tree/ apologies for > the messy UI, I'm still working on updating my CGit stylesheets and as > you can probably also tell I'm not a designer. > > Hopefully this all makes sense :) > > Thanks for your time! > > > Cheers, > > Tom > -- Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: SCSH libraries search path 2022-11-06 10:13 ` Efraim Flashner @ 2022-11-14 0:49 ` Tom Willemse 2022-11-14 12:47 ` Efraim Flashner 0 siblings, 1 reply; 6+ messages in thread From: Tom Willemse @ 2022-11-14 0:49 UTC (permalink / raw) To: Efraim Flashner; +Cc: help-guix Hey Efraim, Efraim Flashner <efraim@flashner.co.il> writes: > On Mon, Oct 31, 2022 at 12:18:50AM -0700, Tom Willemse wrote: >> Hey Guix \o/ >> >> I've been wanting to package one of my little scripts in Guix Home and >> it uses a little library I wrote for SCSH. I've been looking at how >> Search Paths work and I'm having trouble figuring out how to make this >> work. >> >> Search paths seem easy enough generally, I was able to add a simple >> addition to my configuration by just adding this to the scsh package >> definition: >> >> (native-search-paths >> (list (search-path-specification >> (variable "SCSH_LIB_DIRS") >> (files '("share/scsh/site"))))) > > Try adding the 'separator' field, so it would look like this: > > (native-search-paths > (list (search-path-specification > (variable "SCSH_LIB_DIRS") > (separator " ") > (files '("share/scsh/site"))))) Thanks for the suggestion! Unfortunately this gets me a value of `SCSH_LIB_DIRS' like /home/chelys/.guix-home/profile/share/scsh-0.7 which, when I try the command `scsh -ll mpd.scm -o mpd' causes the following error to appear: error: Illegal path element in $SCSH_LIB_DIRS $SCSH_LIB_DIRS: /home/chelys/.guix-home/profile/share/scsh-0.7 The following element is not a string or #f: /home/chelys/.guix-home/profile/share/scsh-0.7 It's because SCSH treats the contents of `SCSH_LIB_DIRS' as "a sequence of of s-expressions, which are `read' from the string"[1] and supports either string values or the value #f. So `SCSH_LIB_DIRS' would have to be in this case: "/home/chelys/.guix-home/profile/share/scsh-0.7" I guess this just isn't supported as yet in Guix? Cheers, Tom ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: SCSH libraries search path 2022-11-14 0:49 ` Tom Willemse @ 2022-11-14 12:47 ` Efraim Flashner 2022-11-24 6:39 ` Tom Willemse 0 siblings, 1 reply; 6+ messages in thread From: Efraim Flashner @ 2022-11-14 12:47 UTC (permalink / raw) To: Tom Willemse; +Cc: help-guix [-- Attachment #1.1: Type: text/plain, Size: 2977 bytes --] On Sun, Nov 13, 2022 at 04:49:05PM -0800, Tom Willemse wrote: > Hey Efraim, > > Efraim Flashner <efraim@flashner.co.il> writes: > > > On Mon, Oct 31, 2022 at 12:18:50AM -0700, Tom Willemse wrote: > >> Hey Guix \o/ > >> > >> I've been wanting to package one of my little scripts in Guix Home and > >> it uses a little library I wrote for SCSH. I've been looking at how > >> Search Paths work and I'm having trouble figuring out how to make this > >> work. > >> > >> Search paths seem easy enough generally, I was able to add a simple > >> addition to my configuration by just adding this to the scsh package > >> definition: > >> > >> (native-search-paths > >> (list (search-path-specification > >> (variable "SCSH_LIB_DIRS") > >> (files '("share/scsh/site"))))) > > > > Try adding the 'separator' field, so it would look like this: > > > > (native-search-paths > > (list (search-path-specification > > (variable "SCSH_LIB_DIRS") > > (separator " ") > > (files '("share/scsh/site"))))) > > Thanks for the suggestion! Unfortunately this gets me a value of > `SCSH_LIB_DIRS' like > > /home/chelys/.guix-home/profile/share/scsh-0.7 > > which, when I try the command `scsh -ll mpd.scm -o mpd' causes the > following error to appear: > > error: Illegal path element in $SCSH_LIB_DIRS > $SCSH_LIB_DIRS: /home/chelys/.guix-home/profile/share/scsh-0.7 > The following element is not a string or #f: /home/chelys/.guix-home/profile/share/scsh-0.7 > > It's because SCSH treats the contents of `SCSH_LIB_DIRS' as "a sequence > of of s-expressions, which are `read' from the string"[1] and supports > either string values or the value #f. So `SCSH_LIB_DIRS' would have to > be in this case: > > "/home/chelys/.guix-home/profile/share/scsh-0.7" > > I guess this just isn't supported as yet in Guix? > I played around with a bunch of different options, and I wasn't able to get the search-path-specification to pass the directories as strings. If we change the file-type to 'string then it looks for strings, but it really means it's looking for individual files or for directories, so that's not the right change. IMO the easiest way to work around it (from scsh, not from guix) would be to use 'stringify' from (scheme utilities) in (scheme lib-dirs) (for the syntactic sugar around symbol->string) to make all the items in the search path into strings if they aren't already. Actually I have a simple diff I'll send upstream that should take care of it. If you could help test it that'd be great. I haven't been able to create a scenario where I had more than one path in the SCSH_LIB_DIRS. -- Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted [-- Attachment #1.2: scsh-nonstring-search-path.patch --] [-- Type: text/plain, Size: 513 bytes --] diff --git a/scheme/lib-dirs.scm b/scheme/lib-dirs.scm index a1fc009..c630fb4 100644 --- a/scheme/lib-dirs.scm +++ b/scheme/lib-dirs.scm @@ -75,6 +75,7 @@ (let ((val (read))) (cond ((eof-object? val) '()) ((string? val) (cons val (recur))) + ((symbol? val) (cons (symbol->string val) (recur))) ((not val) (append default-lib-dirs (recur))) (else (error [-- Attachment #1.3: guix-scsh-with-search-paths.diff --] [-- Type: text/plain, Size: 2443 bytes --] diff --git a/gnu/local.mk b/gnu/local.mk index bda6df1280..56727769df 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1833,6 +1833,7 @@ dist_patch_DATA = \ %D%/packages/patches/sbcl-clml-fix-types.patch \ %D%/packages/patches/sbcl-png-fix-sbcl-compatibility.patch \ %D%/packages/patches/scalapack-gcc-10-compilation.patch \ + %D%/packages/patches/scsh-nonstring-search-path.patch \ %D%/packages/patches/scheme48-tests.patch \ %D%/packages/patches/scons-test-environment.patch \ %D%/packages/patches/screen-hurd-path-max.patch \ diff --git a/gnu/packages/patches/scsh-nonstring-search-path.patch b/gnu/packages/patches/scsh-nonstring-search-path.patch new file mode 100644 index 0000000000..c79e6cc51e --- /dev/null +++ b/gnu/packages/patches/scsh-nonstring-search-path.patch @@ -0,0 +1,12 @@ +diff --git a/scheme/lib-dirs.scm b/scheme/lib-dirs.scm +index a1fc009..c630fb4 100644 +--- a/scheme/lib-dirs.scm ++++ b/scheme/lib-dirs.scm +@@ -75,6 +75,7 @@ + (let ((val (read))) + (cond ((eof-object? val) '()) + ((string? val) (cons val (recur))) ++ ((symbol? val) (cons (symbol->string val) (recur))) + ((not val) (append default-lib-dirs (recur))) + (else + (error diff --git a/gnu/packages/shells.scm b/gnu/packages/shells.scm index cc34f0a0a0..c5ceb3192b 100644 --- a/gnu/packages/shells.scm +++ b/gnu/packages/shells.scm @@ -613,7 +613,8 @@ (define-public scsh (file-name (string-append name "-" version "-checkout")) (sha256 (base32 - "1ghk08akiz7hff1pndi8rmgamgcrn2mv9asbss9l79d3c2iaav3q")))) + "1ghk08akiz7hff1pndi8rmgamgcrn2mv9asbss9l79d3c2iaav3q")) + (patches (search-patches "scsh-nonstring-search-path.patch")))) (build-system gnu-build-system) (arguments `(#:test-target "test" @@ -632,6 +633,11 @@ (define-public scsh (list scheme48 scheme48-rx)) (native-inputs (list autoconf automake)) + (native-search-paths + (list (search-path-specification + (variable "SCSH_LIB_DIRS") + (separator " ") + (files '("share/scsh-0.7"))))) (home-page "https://github.com/scheme/scsh") (synopsis "Unix shell embedded in Scheme") (description [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: SCSH libraries search path 2022-11-14 12:47 ` Efraim Flashner @ 2022-11-24 6:39 ` Tom Willemse 2023-02-16 15:42 ` Efraim Flashner 0 siblings, 1 reply; 6+ messages in thread From: Tom Willemse @ 2022-11-24 6:39 UTC (permalink / raw) To: Efraim Flashner; +Cc: help-guix Hey Efraim, Efraim Flashner <efraim@flashner.co.il> writes: > On Sun, Nov 13, 2022 at 04:49:05PM -0800, Tom Willemse wrote: >> Hey Efraim, >> >> Efraim Flashner <efraim@flashner.co.il> writes: >> >> > On Mon, Oct 31, 2022 at 12:18:50AM -0700, Tom Willemse wrote: >> >> Hey Guix \o/ >> >> >> >> I've been wanting to package one of my little scripts in Guix Home and >> >> it uses a little library I wrote for SCSH. I've been looking at how >> >> Search Paths work and I'm having trouble figuring out how to make this >> >> work. >> >> >> >> Search paths seem easy enough generally, I was able to add a simple >> >> addition to my configuration by just adding this to the scsh package >> >> definition: >> >> >> >> (native-search-paths >> >> (list (search-path-specification >> >> (variable "SCSH_LIB_DIRS") >> >> (files '("share/scsh/site"))))) >> > >> > Try adding the 'separator' field, so it would look like this: >> > >> > (native-search-paths >> > (list (search-path-specification >> > (variable "SCSH_LIB_DIRS") >> > (separator " ") >> > (files '("share/scsh/site"))))) >> >> Thanks for the suggestion! Unfortunately this gets me a value of >> `SCSH_LIB_DIRS' like >> >> /home/chelys/.guix-home/profile/share/scsh-0.7 >> >> which, when I try the command `scsh -ll mpd.scm -o mpd' causes the >> following error to appear: >> >> error: Illegal path element in $SCSH_LIB_DIRS >> $SCSH_LIB_DIRS: /home/chelys/.guix-home/profile/share/scsh-0.7 >> The following element is not a string or #f: /home/chelys/.guix-home/profile/share/scsh-0.7 >> >> It's because SCSH treats the contents of `SCSH_LIB_DIRS' as "a sequence >> of of s-expressions, which are `read' from the string"[1] and supports >> either string values or the value #f. So `SCSH_LIB_DIRS' would have to >> be in this case: >> >> "/home/chelys/.guix-home/profile/share/scsh-0.7" >> >> I guess this just isn't supported as yet in Guix? >> > > I played around with a bunch of different options, and I wasn't able to > get the search-path-specification to pass the directories as strings. If > we change the file-type to 'string then it looks for strings, but it > really means it's looking for individual files or for directories, so > that's not the right change. > > IMO the easiest way to work around it (from scsh, not from guix) would > be to use 'stringify' from (scheme utilities) in (scheme lib-dirs) (for > the syntactic sugar around symbol->string) to make all the items in the > search path into strings if they aren't already. I've tried out your changes and it seems to work just great for my little module so far, thank you! > Actually I have a simple diff I'll send upstream that should take care > of it. If you could help test it that'd be great. I haven't been able to > create a scenario where I had more than one path in the SCSH_LIB_DIRS. I don't know how I would get more than one value in there with Guix, but manually adding another path in there works fine: > 22:36 ~ [1]> export SCSH_LIB_DIRS="\"${HOME}/usr/share/scsh/\" ${SCSH_LIB_DIRS}" > 22:37 ~ [130]> echo $SCSH_LIB_DIRS > "/home/chelys/usr/share/scsh/" /home/chelys/.guix-home/profile/share/scsh-0.7 > 22:37 ~ > scsh -ll mpd.scm -o mpd -ll herbstluft.scm -o herbstluft > Welcome to scsh 0.7 > Type ,? for help. > > (query (and (= artist "Danko Jones") (= album "Garage Rock"))) > "((artist == \"Danko Jones\") AND (album == \"Garage Rock\"))" > > (hc get_attr "my_wallpaper") > /home/chelys/pictures/wallpaper/5120x1440/nfbq2nw3rsm81.jpg > 0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: SCSH libraries search path 2022-11-24 6:39 ` Tom Willemse @ 2023-02-16 15:42 ` Efraim Flashner 0 siblings, 0 replies; 6+ messages in thread From: Efraim Flashner @ 2023-02-16 15:42 UTC (permalink / raw) To: Tom Willemse; +Cc: help-guix [-- Attachment #1: Type: text/plain, Size: 4395 bytes --] On Wed, Nov 23, 2022 at 10:39:35PM -0800, Tom Willemse wrote: > Hey Efraim, > > Efraim Flashner <efraim@flashner.co.il> writes: > > > On Sun, Nov 13, 2022 at 04:49:05PM -0800, Tom Willemse wrote: > >> Hey Efraim, > >> > >> Efraim Flashner <efraim@flashner.co.il> writes: > >> > >> > On Mon, Oct 31, 2022 at 12:18:50AM -0700, Tom Willemse wrote: > >> >> Hey Guix \o/ > >> >> > >> >> I've been wanting to package one of my little scripts in Guix Home and > >> >> it uses a little library I wrote for SCSH. I've been looking at how > >> >> Search Paths work and I'm having trouble figuring out how to make this > >> >> work. > >> >> > >> >> Search paths seem easy enough generally, I was able to add a simple > >> >> addition to my configuration by just adding this to the scsh package > >> >> definition: > >> >> > >> >> (native-search-paths > >> >> (list (search-path-specification > >> >> (variable "SCSH_LIB_DIRS") > >> >> (files '("share/scsh/site"))))) > >> > > >> > Try adding the 'separator' field, so it would look like this: > >> > > >> > (native-search-paths > >> > (list (search-path-specification > >> > (variable "SCSH_LIB_DIRS") > >> > (separator " ") > >> > (files '("share/scsh/site"))))) > >> > >> Thanks for the suggestion! Unfortunately this gets me a value of > >> `SCSH_LIB_DIRS' like > >> > >> /home/chelys/.guix-home/profile/share/scsh-0.7 > >> > >> which, when I try the command `scsh -ll mpd.scm -o mpd' causes the > >> following error to appear: > >> > >> error: Illegal path element in $SCSH_LIB_DIRS > >> $SCSH_LIB_DIRS: /home/chelys/.guix-home/profile/share/scsh-0.7 > >> The following element is not a string or #f: /home/chelys/.guix-home/profile/share/scsh-0.7 > >> > >> It's because SCSH treats the contents of `SCSH_LIB_DIRS' as "a sequence > >> of of s-expressions, which are `read' from the string"[1] and supports > >> either string values or the value #f. So `SCSH_LIB_DIRS' would have to > >> be in this case: > >> > >> "/home/chelys/.guix-home/profile/share/scsh-0.7" > >> > >> I guess this just isn't supported as yet in Guix? > >> > > > > I played around with a bunch of different options, and I wasn't able to > > get the search-path-specification to pass the directories as strings. If > > we change the file-type to 'string then it looks for strings, but it > > really means it's looking for individual files or for directories, so > > that's not the right change. > > > > IMO the easiest way to work around it (from scsh, not from guix) would > > be to use 'stringify' from (scheme utilities) in (scheme lib-dirs) (for > > the syntactic sugar around symbol->string) to make all the items in the > > search path into strings if they aren't already. > > I've tried out your changes and it seems to work just great for my > little module so far, thank you! > > > Actually I have a simple diff I'll send upstream that should take care > > of it. If you could help test it that'd be great. I haven't been able to > > create a scenario where I had more than one path in the SCSH_LIB_DIRS. > > I don't know how I would get more than one value in there with Guix, but > manually adding another path in there works fine: > > > 22:36 ~ [1]> export SCSH_LIB_DIRS="\"${HOME}/usr/share/scsh/\" ${SCSH_LIB_DIRS}" > > 22:37 ~ [130]> echo $SCSH_LIB_DIRS > > "/home/chelys/usr/share/scsh/" /home/chelys/.guix-home/profile/share/scsh-0.7 > > 22:37 ~ > scsh -ll mpd.scm -o mpd -ll herbstluft.scm -o herbstluft > > Welcome to scsh 0.7 > > Type ,? for help. > > > (query (and (= artist "Danko Jones") (= album "Garage Rock"))) > > "((artist == \"Danko Jones\") AND (album == \"Garage Rock\"))" > > > (hc get_attr "my_wallpaper") > > /home/chelys/pictures/wallpaper/5120x1440/nfbq2nw3rsm81.jpg > > 0 I was waiting for upstream to apply the patch and then I realized it had been a while and figured I'd just add it here also. Patch finally applied, scsh now uses the search path SCSH_LIB_DIRS. -- Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-16 15:42 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-10-31 7:18 SCSH libraries search path Tom Willemse 2022-11-06 10:13 ` Efraim Flashner 2022-11-14 0:49 ` Tom Willemse 2022-11-14 12:47 ` Efraim Flashner 2022-11-24 6:39 ` Tom Willemse 2023-02-16 15:42 ` Efraim Flashner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).