* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
@ 2019-05-31 10:36 Dan Frumin
2019-05-31 10:41 ` Dan Frumin
0 siblings, 1 reply; 8+ messages in thread
From: Dan Frumin @ 2019-05-31 10:36 UTC (permalink / raw)
To: 36021; +Cc: Dan Frumin
---
guix/search-paths.scm | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/guix/search-paths.scm b/guix/search-paths.scm
index 002e6342bb..fe9253e88e 100644
--- a/guix/search-paths.scm
+++ b/guix/search-paths.scm
@@ -177,15 +177,28 @@ current value), or 'suffix (return the definition where VALUE is added as a
suffix to VARIABLE's current value.) In the case of 'prefix and 'suffix,
SEPARATOR is used as the separator between VARIABLE's current value and its
prefix/suffix."
- (match (if (not separator) 'exact kind)
- ('exact
- (format #f "export ~a=\"~a\"" variable value))
- ('prefix
- (format #f "export ~a=\"~a${~a:+~a}$~a\""
- variable value variable separator variable))
- ('suffix
- (format #f "export ~a=\"$~a${~a:+~a}~a\""
- variable variable variable separator value))))
+ (let* ([shell-env (getenv "SHELL")]
+ [is-fish? (and shell-env
+ (equal? (last (string-split shell-env #\/))
+ "fish"))])
+ (match (if (not separator) 'exact kind)
+ ('exact
+ (if is-fish?
+ ;; See <https://fishshell.com/docs/current/commands.html#set> for syntax
+ (format #f "set -x ~a \"~a\"" variable value)
+ (format #f "export ~a=\"~a\"" variable value)))
+ ('prefix
+ (if is-fish?
+ (format #f "set -x ~a \"~a\" $~a"
+ variable value variable)
+ (format #f "export ~a=\"~a${~a:+~a}$~a\""
+ variable value variable separator variable)))
+ ('suffix
+ (if is-fish?
+ (format #f "set -x ~a $~a \"~a\""
+ variable variable value)
+ (format #f "export ~a=\"$~a${~a:+~a}~a\""
+ variable variable variable separator value))))))
(define* (search-path-definition search-path value
#:key (kind 'exact))
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
2019-05-31 10:36 [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish Dan Frumin
@ 2019-05-31 10:41 ` Dan Frumin
2019-06-01 13:10 ` Ludovic Courtès
2019-06-03 5:51 ` Meiyo Peng
0 siblings, 2 replies; 8+ messages in thread
From: Dan Frumin @ 2019-05-31 10:41 UTC (permalink / raw)
To: 36021
Hi Guix!
Some background on this patch:
Right now whenever I do any Guix operation that requires me to modify environment variables (e.g. installing a Guile library requires me to update
$GUILE_LOAD_PATH afterwards), Guix helpful tells me what commands I have to run to update the variables.
However, those commands are currently in bash/POSIX(?) format `export VAR=VALUE`. I've modified the `environment-variable-definition` function to
support the syntax for Fish shell as well. I don't know if this method of looking at the $SHELL variable is sound, but it works on my machine.
Documentation for the `set' function in Fish: https://fishshell.com/docs/current/commands.html#set
PS: this is my first non-package patch for Guix so I apologize if there is something wrong with the patch
Best regards,
-Dan
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
2019-05-31 10:41 ` Dan Frumin
@ 2019-06-01 13:10 ` Ludovic Courtès
2019-06-02 9:29 ` Dan Frumin
2019-06-03 5:51 ` Meiyo Peng
1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2019-06-01 13:10 UTC (permalink / raw)
To: Dan Frumin; +Cc: 36021
Hi,
Dan Frumin <dfrumin@cs.ru.nl> skribis:
> Some background on this patch:
> Right now whenever I do any Guix operation that requires me to modify
> environment variables (e.g. installing a Guile library requires me to
> update $GUILE_LOAD_PATH afterwards), Guix helpful tells me what
> commands I have to run to update the variables.
But see <https://issues.guix.gnu.org/issue/35942>. :-)
> However, those commands are currently in bash/POSIX(?) format `export
> VAR=VALUE`. I've modified the `environment-variable-definition`
> function to support the syntax for Fish shell as well. I don't know if
> this method of looking at the $SHELL variable is sound, but it works
> on my machine.
“export VAR=VALUE” is actually Bash-specific. The POSIX way to do it
is:
VAR=VALUE; export VAR
Would that work with Fish?
If it does, we might just as well take that route as it will also cater
to other POSIX-compatible shells.
If not, your patch sounds like the right way.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
2019-06-01 13:10 ` Ludovic Courtès
@ 2019-06-02 9:29 ` Dan Frumin
0 siblings, 0 replies; 8+ messages in thread
From: Dan Frumin @ 2019-06-02 9:29 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 36021
Hi Ludovic,
On 01-06-19 15:10, Ludovic Courtès wrote:
> Hi,
>
> Dan Frumin <dfrumin@cs.ru.nl> skribis:
>
>> Some background on this patch:
>> Right now whenever I do any Guix operation that requires me to modify
>> environment variables (e.g. installing a Guile library requires me to
>> update $GUILE_LOAD_PATH afterwards), Guix helpful tells me what
>> commands I have to run to update the variables.
>
> But see <https://issues.guix.gnu.org/issue/35942>. :-)
>
I was actually oblivious to the fact that these environment variables can be set up for you automatically in a new shell -- I guess that's because
both ~/.guix-profile/etc/profile and `guix package --search-paths` output everything in Bash format, so I didn't use it with Fish.
>> However, those commands are currently in bash/POSIX(?) format `export
>> VAR=VALUE`. I've modified the `environment-variable-definition`
>> function to support the syntax for Fish shell as well. I don't know if
>> this method of looking at the $SHELL variable is sound, but it works
>> on my machine.
>
> “export VAR=VALUE” is actually Bash-specific. The POSIX way to do it
> is:
>
> VAR=VALUE; export VAR
>
> Would that work with Fish?
Unfortunately not. I wish they'd support more standard features.
Best,
Dan
>
> If it does, we might just as well take that route as it will also cater
> to other POSIX-compatible shells.
>
> If not, your patch sounds like the right way.
>
> Thanks,
> Ludo’.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
2019-05-31 10:41 ` Dan Frumin
2019-06-01 13:10 ` Ludovic Courtès
@ 2019-06-03 5:51 ` Meiyo Peng
2019-06-03 15:50 ` Dan Frumin
1 sibling, 1 reply; 8+ messages in thread
From: Meiyo Peng @ 2019-06-03 5:51 UTC (permalink / raw)
To: Dan Frumin; +Cc: 36021
Hi Dan,
Dan Frumin writes:
> Some background on this patch:
> Right now whenever I do any Guix operation that requires me to modify
> environment variables (e.g. installing a Guile library requires me to update
> $GUILE_LOAD_PATH afterwards), Guix helpful tells me what commands I have to run
> to update the variables.
>
> However, those commands are currently in bash/POSIX(?) format `export
> VAR=VALUE`. I've modified the `environment-variable-definition` function to
> support the syntax for Fish shell as well. I don't know if this method of
> looking at the $SHELL variable is sound, but it works on my machine.
>
> Documentation for the `set' function in Fish: https://fishshell.com/docs/current/commands.html#set
>
> PS: this is my first non-package patch for Guix so I apologize if there is something wrong with the patch
I think this patch will cause more trouble than good. Does this patch
replaces etc/profile with fish syntax script? etc/profile is supposed
to be in POSIX shell syntax. Fish shell has it's own configuration
files in /etc/fish/config.fish and /etc/fish/conf.d/*.fish. If you
really want to generate fish syntax scripts, please put them in
/etc/fish/config.fish or /etc/fish/conf.d/*.fish.
See:
1. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00071.html
2. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00333.html
3. https://issues.guix.gnu.org/issue/34153
Have you tried the fish-foreign-env package? You can source bash
scripts in fish via `fenv source ~/.guix-profile/etc/profile`. That's how
the fish shell in Guix set up environment variables upon login.
Perhaps we can handle this better. Do you have any suggestions? My
idea:
1. The fish-foreign-env package is very useful but it's not installed by
default in order to avoid polluting user's profiles according to the
Guix convention. In this case I think it's a useful utility rather than
pollution. Do you want it to be installed together with the fish
package by default?
2. etc/profile is supposed to be sourced by a login shell. And we
should avoid sourcing it from a non-login shell. That's why I made the
fish package in Guix only sources it upon login. That means starting a
new fish shell won't source it automatically. So please source it
manually if you need the new environment variables (fenv source
~/.guix-profile/etc/profile).
3. We can write better documentations explaining how to deal with fish
shell in Guix. There's an old discussion about having a Guix wiki or
a Guix book.
--
Meiyo Peng
https://www.pengmeiyu.com/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
2019-06-03 5:51 ` Meiyo Peng
@ 2019-06-03 15:50 ` Dan Frumin
2019-06-04 3:53 ` Meiyo Peng
0 siblings, 1 reply; 8+ messages in thread
From: Dan Frumin @ 2019-06-03 15:50 UTC (permalink / raw)
To: Meiyo Peng; +Cc: 36021
Hi Meiyo,
On 03-06-19 07:51, Meiyo Peng wrote:
> Hi Dan,
>
> Dan Frumin writes:
>
>> Some background on this patch:
>> Right now whenever I do any Guix operation that requires me to modify
>> environment variables (e.g. installing a Guile library requires me to update
>> $GUILE_LOAD_PATH afterwards), Guix helpful tells me what commands I have to run
>> to update the variables.
>>
>> However, those commands are currently in bash/POSIX(?) format `export
>> VAR=VALUE`. I've modified the `environment-variable-definition` function to
>> support the syntax for Fish shell as well. I don't know if this method of
>> looking at the $SHELL variable is sound, but it works on my machine.
>>
>> Documentation for the `set' function in Fish: https://fishshell.com/docs/current/commands.html#set
>>
>> PS: this is my first non-package patch for Guix so I apologize if there is something wrong with the patch
>
> I think this patch will cause more trouble than good. Does this patch
> replaces etc/profile with fish syntax script? etc/profile is supposed
> to be in POSIX shell syntax. Fish shell has it's own configuration
> files in /etc/fish/config.fish and /etc/fish/conf.d/*.fish. If you
> really want to generate fish syntax scripts, please put them in
> /etc/fish/config.fish or /etc/fish/conf.d/*.fish.
>
No, this patch doesn't touch etc/profile in any way, it is only concerned with the output that you get from `guix package` on your terminal.
So I guess it's kind of orthogonal to the upgraded fish package that you made?
> See:
> 1. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00071.html
> 2. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00333.html
> 3. https://issues.guix.gnu.org/issue/34153
>
> Have you tried the fish-foreign-env package? You can source bash
> scripts in fish via `fenv source ~/.guix-profile/etc/profile`. That's how
> the fish shell in Guix set up environment variables upon login.
>
Thanks! This is quite nice, I should upgrade my Fish installation.
> Perhaps we can handle this better. Do you have any suggestions? My
> idea:
>
> 1. The fish-foreign-env package is very useful but it's not installed by
> default in order to avoid polluting user's profiles according to the
> Guix convention. In this case I think it's a useful utility rather than
> pollution. Do you want it to be installed together with the fish
> package by default?
Well, you added it as part of the fish dependency, right? I think it makes sense, especially on Guix SD.
>
> 2. etc/profile is supposed to be sourced by a login shell. And we
> should avoid sourcing it from a non-login shell. That's why I made the
> fish package in Guix only sources it upon login. That means starting a
> new fish shell won't source it automatically. So please source it
> manually if you need the new environment variables (fenv source
> ~/.guix-profile/etc/profile).
I am not knowledgeable enough to comment on this, but it seems to me that it is done similarly if you are using bash: e.g. you have to source the
profile yourself if you want to get it in a non-login shell.
>
> 3. We can write better documentations explaining how to deal with fish
> shell in Guix. There's an old discussion about having a Guix wiki or
> a Guix book.
>
Yeah, more documentation is always better :)
Best regards,
-Dan
>
> --
> Meiyo Peng
> https://www.pengmeiyu.com/
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
2019-06-03 15:50 ` Dan Frumin
@ 2019-06-04 3:53 ` Meiyo Peng
2019-06-04 7:48 ` Dan Frumin
0 siblings, 1 reply; 8+ messages in thread
From: Meiyo Peng @ 2019-06-04 3:53 UTC (permalink / raw)
To: Dan Frumin; +Cc: 36021
Hi Dan,
Dan Frumin writes:
>>> Some background on this patch:
>>> Right now whenever I do any Guix operation that requires me to modify
>>> environment variables (e.g. installing a Guile library requires me to update
>>> $GUILE_LOAD_PATH afterwards), Guix helpful tells me what commands I have to run
>>> to update the variables.
>>>
>>> However, those commands are currently in bash/POSIX(?) format `export
>>> VAR=VALUE`. I've modified the `environment-variable-definition` function to
>>> support the syntax for Fish shell as well. I don't know if this method of
>>> looking at the $SHELL variable is sound, but it works on my machine.
>>>
>>> Documentation for the `set' function in Fish: https://fishshell.com/docs/current/commands.html#set
>>>
>>> PS: this is my first non-package patch for Guix so I apologize if there is something wrong with the patch
>>
>> I think this patch will cause more trouble than good. Does this patch
>> replaces etc/profile with fish syntax script? etc/profile is supposed
>> to be in POSIX shell syntax. Fish shell has it's own configuration
>> files in /etc/fish/config.fish and /etc/fish/conf.d/*.fish. If you
>> really want to generate fish syntax scripts, please put them in
>> /etc/fish/config.fish or /etc/fish/conf.d/*.fish.
>>
>
> No, this patch doesn't touch etc/profile in any way, it is only concerned with the output that you get from `guix package` on your terminal.
> So I guess it's kind of orthogonal to the upgraded fish package that you made?
Alright. Then that's fine. But there is an on going discussion about
change content of the message in bug #35942. I suggest we hold this
patch until that bug is closed.
>> See:
>> 1. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00071.html
>> 2. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00333.html
>> 3. https://issues.guix.gnu.org/issue/34153
>>
>> Have you tried the fish-foreign-env package? You can source bash
>> scripts in fish via `fenv source ~/.guix-profile/etc/profile`. That's how
>> the fish shell in Guix set up environment variables upon login.
>>
>
> Thanks! This is quite nice, I should upgrade my Fish installation.
Your fish shell is quite old. Older than Guix 1.0.0!
>> Perhaps we can handle this better. Do you have any suggestions? My
>> idea:
>>
>> 1. The fish-foreign-env package is very useful but it's not installed by
>> default in order to avoid polluting user's profiles according to the
>> Guix convention. In this case I think it's a useful utility rather than
>> pollution. Do you want it to be installed together with the fish
>> package by default?
>
> Well, you added it as part of the fish dependency, right? I think it makes sense, especially on Guix SD.
Yes, it's a dependency of fish. But it's not a propagated input. We
can change it into a propagated input if most users agree.
>> 2. etc/profile is supposed to be sourced by a login shell. And we
>> should avoid sourcing it from a non-login shell. That's why I made the
>> fish package in Guix only sources it upon login. That means starting a
>> new fish shell won't source it automatically. So please source it
>> manually if you need the new environment variables (fenv source
>> ~/.guix-profile/etc/profile).
>
> I am not knowledgeable enough to comment on this, but it seems to me that it is
> done similarly if you are using bash: e.g. you have to source the profile
> yourself if you want to get it in a non-login shell.
>
>>
>> 3. We can write better documentations explaining how to deal with fish
>> shell in Guix. There's an old discussion about having a Guix wiki or
>> a Guix book.
>>
>
> Yeah, more documentation is always better :)
--
Meiyo Peng
https://www.pengmeiyu.com/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish
2019-06-04 3:53 ` Meiyo Peng
@ 2019-06-04 7:48 ` Dan Frumin
0 siblings, 0 replies; 8+ messages in thread
From: Dan Frumin @ 2019-06-04 7:48 UTC (permalink / raw)
To: 36021
Hi,
On 04-06-19 05:53, Meiyo Peng wrote:
> Hi Dan,
>
> Dan Frumin writes:
>
>>>> Some background on this patch:
>>>> Right now whenever I do any Guix operation that requires me to modify
>>>> environment variables (e.g. installing a Guile library requires me to update
>>>> $GUILE_LOAD_PATH afterwards), Guix helpful tells me what commands I have to run
>>>> to update the variables.
>>>>
>>>> However, those commands are currently in bash/POSIX(?) format `export
>>>> VAR=VALUE`. I've modified the `environment-variable-definition` function to
>>>> support the syntax for Fish shell as well. I don't know if this method of
>>>> looking at the $SHELL variable is sound, but it works on my machine.
>>>>
>>>> Documentation for the `set' function in Fish: https://fishshell.com/docs/current/commands.html#set
>>>>
>>>> PS: this is my first non-package patch for Guix so I apologize if there is something wrong with the patch
>>>
>>> I think this patch will cause more trouble than good. Does this patch
>>> replaces etc/profile with fish syntax script? etc/profile is supposed
>>> to be in POSIX shell syntax. Fish shell has it's own configuration
>>> files in /etc/fish/config.fish and /etc/fish/conf.d/*.fish. If you
>>> really want to generate fish syntax scripts, please put them in
>>> /etc/fish/config.fish or /etc/fish/conf.d/*.fish.
>>>
>>
>> No, this patch doesn't touch etc/profile in any way, it is only concerned with the output that you get from `guix package` on your terminal.
>> So I guess it's kind of orthogonal to the upgraded fish package that you made?
>
> Alright. Then that's fine. But there is an on going discussion about
> change content of the message in bug #35942. I suggest we hold this
> patch until that bug is closed.
>
Sure, makes sense to me.
>>> See:
>>> 1. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00071.html
>>> 2. https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00333.html
>>> 3. https://issues.guix.gnu.org/issue/34153
>>>
>>> Have you tried the fish-foreign-env package? You can source bash
>>> scripts in fish via `fenv source ~/.guix-profile/etc/profile`. That's how
>>> the fish shell in Guix set up environment variables upon login.
>>>
>>
>> Thanks! This is quite nice, I should upgrade my Fish installation.
>
> Your fish shell is quite old. Older than Guix 1.0.0!
>
>>> Perhaps we can handle this better. Do you have any suggestions? My
>>> idea:
>>>
>>> 1. The fish-foreign-env package is very useful but it's not installed by
>>> default in order to avoid polluting user's profiles according to the
>>> Guix convention. In this case I think it's a useful utility rather than
>>> pollution. Do you want it to be installed together with the fish
>>> package by default?
>>
>> Well, you added it as part of the fish dependency, right? I think it makes sense, especially on Guix SD.
>
> Yes, it's a dependency of fish. But it's not a propagated input. We
> can change it into a propagated input if most users agree.
>
>>> 2. etc/profile is supposed to be sourced by a login shell. And we
>>> should avoid sourcing it from a non-login shell. That's why I made the
>>> fish package in Guix only sources it upon login. That means starting a
>>> new fish shell won't source it automatically. So please source it
>>> manually if you need the new environment variables (fenv source
>>> ~/.guix-profile/etc/profile).
>>
>> I am not knowledgeable enough to comment on this, but it seems to me that it is
>> done similarly if you are using bash: e.g. you have to source the profile
>> yourself if you want to get it in a non-login shell.
>>
>>>
>>> 3. We can write better documentations explaining how to deal with fish
>>> shell in Guix. There's an old discussion about having a Guix wiki or
>>> a Guix book.
>>>
>>
>> Yeah, more documentation is always better :)
>
>
> --
> Meiyo Peng
> https://www.pengmeiyu.com/
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-06-04 7:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-31 10:36 [bug#36021] [PATCH] search-paths: 'environment-variable-definition' output for fish Dan Frumin
2019-05-31 10:41 ` Dan Frumin
2019-06-01 13:10 ` Ludovic Courtès
2019-06-02 9:29 ` Dan Frumin
2019-06-03 5:51 ` Meiyo Peng
2019-06-03 15:50 ` Dan Frumin
2019-06-04 3:53 ` Meiyo Peng
2019-06-04 7:48 ` Dan Frumin
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.