all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* guix environment shebang interpreter
@ 2020-01-21  0:02 EuAndreh via
  2020-02-06 10:37 ` mlell
  0 siblings, 1 reply; 5+ messages in thread
From: EuAndreh via @ 2020-01-21  0:02 UTC (permalink / raw)
  To: help-guix

Hi Guix!

Is there a Guix equivalent of the nix-shell shebang?

Sample from Nix documentation
(https://nixos.org/nix/manual/#use-as-a-interpreter):

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env nix-shell
#!nix-shell -i perl -p perl perlPackages.HTMLTokeParserSimple perlPackages.LWP

use HTML::TokeParser::Simple;

...
--8<---------------cut here---------------end--------------->8---

Can I already accomplish this with Guix? If so, how?

I tried searching previous discussions of this topic on Guix mailing
lists, but couldn't find any. If this was disscussed before, could
anyone point me to the thread?

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: guix environment shebang interpreter
  2020-01-21  0:02 EuAndreh via
@ 2020-02-06 10:37 ` mlell
  2020-02-13 15:43   ` EuAndreh via
  0 siblings, 1 reply; 5+ messages in thread
From: mlell @ 2020-02-06 10:37 UTC (permalink / raw)
  To: EuAndreh; +Cc: Help-Guix, help-guix

Hi!

> Is there a Guix equivalent of the nix-shell shebang?
> 

You could imagine something like:

     #! /usr/bin/env guix environment --ad-hoc PKG1 PKG2 ... -- 
INTERPRETER


But alas,  on linux you cannot put more than one argument in the shebang 
line.

See this discussion: 
https://unix.stackexchange.com/questions/399690/multiple-arguments-in-shebang

But, one answer there has a possible solution for you: 
https://unix.stackexchange.com/a/399698

--8<-------------------------------------------------------
#!/bin/sh -

if [ "$1" != "--really" ]; then exec bash --posix -- "$0" --really "$@"; 
fi

shift

# Processing continues
----------------------------------------------->8-----------

It lets the script `exec` itself with the right arguments! So maybe put

     exec guix environment --ad-hoc PKG1 PKG2 ... -- INTERPRETER "$0" 
"$@"

there?


Cheers,
Moritz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: guix environment shebang interpreter
       [not found] <mailman.123.1581008426.401.help-guix@gnu.org>
@ 2020-02-06 23:22 ` John D. Boy
  2020-02-07 14:57   ` mlell
  0 siblings, 1 reply; 5+ messages in thread
From: John D. Boy @ 2020-02-06 23:22 UTC (permalink / raw)
  To: help-guix

> > Is there a Guix equivalent of the nix-shell shebang?
> You could imagine something like:
> 
>      #! /usr/bin/env guix environment --ad-hoc PKG1 PKG2 ... -- 
> INTERPRETER
> 
> But alas,  on linux you cannot put more than one argument in the shebang 
> line.

I have successfully gotten this to work by passing -S to env:
#!/usr/bin/env -S guix environment --ad-hoc python python-pandas python-numpy -- python3

See a short test script here: https://gist.github.com/jboynyc/1faa5dc4e278d5b6284795f780d22764

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: guix environment shebang interpreter
  2020-02-06 23:22 ` guix environment shebang interpreter John D. Boy
@ 2020-02-07 14:57   ` mlell
  0 siblings, 0 replies; 5+ messages in thread
From: mlell @ 2020-02-07 14:57 UTC (permalink / raw)
  To: John D. Boy; +Cc: Help-Guix, help-guix

Great!

however, note that at two different time points, you can get different 
versions of python with
this command as the executing machine might have different versions of 
guix.

Only if you pull a specific version of guix (e.g. with guix pull 
--commit) and have it in your PATH
you will get the same packages.

Best regards,
Moritz

---
OpenPGP: 0xB4CCD0677340821E

Am 07.02.2020 00:22 schrieb John D. Boy:
>> > Is there a Guix equivalent of the nix-shell shebang?
>> You could imagine something like:
>> 
>>      #! /usr/bin/env guix environment --ad-hoc PKG1 PKG2 ... --
>> INTERPRETER
>> 
>> But alas,  on linux you cannot put more than one argument in the 
>> shebang
>> line.
> 
> I have successfully gotten this to work by passing -S to env:
> #!/usr/bin/env -S guix environment --ad-hoc python python-pandas
> python-numpy -- python3
> 
> See a short test script here:
> https://gist.github.com/jboynyc/1faa5dc4e278d5b6284795f780d22764

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: guix environment shebang interpreter
  2020-02-06 10:37 ` mlell
@ 2020-02-13 15:43   ` EuAndreh via
  0 siblings, 0 replies; 5+ messages in thread
From: EuAndreh via @ 2020-02-13 15:43 UTC (permalink / raw)
  To: mlell; +Cc: help-guix, Help-Guix

mlell@posteo.de writes:

> But, one answer there has a possible solution for you:
> https://unix.stackexchange.com/a/399698
>
> --8<-------------------------------------------------------
> #!/bin/sh -
>
> if [ "$1" != "--really" ]; then exec bash --posix -- "$0" --really "$@";
> fi
>
> shift
>
> # Processing continues
> ----------------------------------------------->8-----------
>
> It lets the script `exec` itself with the right arguments! So maybe put
>
>      exec guix environment --ad-hoc PKG1 PKG2 ... -- INTERPRETER "$0"
> "$@"
>
> there?

Hmm, I guess that works. It's a bit ugly but does the job. Thanks for
the link.

I also just wanted to check for the existance of such functionality in
Guix already, before pursuing alternatives.

Thanks Moritz :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-13 16:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.123.1581008426.401.help-guix@gnu.org>
2020-02-06 23:22 ` guix environment shebang interpreter John D. Boy
2020-02-07 14:57   ` mlell
2020-01-21  0:02 EuAndreh via
2020-02-06 10:37 ` mlell
2020-02-13 15:43   ` EuAndreh via

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.