unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Unable to define shebang for guix shell file
@ 2021-11-01  0:08 Jacob Hrbek
  2021-11-09 17:21 ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Jacob Hrbek @ 2021-11-01  0:08 UTC (permalink / raw)
  To: guix-devel@gnu.org


[-- Attachment #1.1.1: Type: text/plain, Size: 1461 bytes --]

I am unable to define a guix shell file with shebang to decrease the complexity needed in the repository managing (so that i can just do ./path/to/guix.scm for guix to invoke `guix shell -f ./path/to/guix.scm` instead of having to sanitize the runtime) as the issue is that POSIX shebang allows only one argument and due to the way we handle reproducibility the shebang has to be `#!/usr/bin/env <command>`

Proposing to integrate guix-shell for this purpose (inspired by NixOS) e.g.

```nix

#!/usr/bin/env nix-shell

# NixOS shell configuration to bootstrap the required dependencies to run and use the editor

# NOTE(Krey): This is designed to contain ONLY editor-specific configuration **NOT** project specific

let

    nivSources = builtins.fetchGit {

        url = "ssh://gitea@git.dotya.ml:RiXotStudio/std-niv.git";

        rev = "7664e29d8ba174cde2e4ff98331fa12e18258b7a"; # 24/10/2021-EU 23:57:10 CEST

        ref = "central";

    };

in {

    sources ? import "${nivSources}/sources.nix",

    nixpkgs ? import sources.nixpkgs {},

}:

with nixpkgs;

    stdenv.mkDerivation {

        name = "RiXotStudio_emacs-config";

        buildInputs = [

            fira-code # Default font with liqurature support

            emacs # Editor

        ];

    }

```

-- Jacob "Kreyren" Hrbek

Sent with ProtonMail Secure Email.

[-- Attachment #1.1.2.1: Type: text/html, Size: 2112 bytes --]

[-- Attachment #1.2: publickey - kreyren@rixotstudio.cz - 0x1677DB82.asc --]
[-- Type: application/pgp-keys, Size: 737 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: Unable to define shebang for guix shell file
  2021-11-01  0:08 Unable to define shebang for guix shell file Jacob Hrbek
@ 2021-11-09 17:21 ` Ludovic Courtès
  2021-11-09 21:35   ` Jacob Hrbek
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2021-11-09 17:21 UTC (permalink / raw)
  To: Jacob Hrbek; +Cc: guix-devel@gnu.org

Hi,

Jacob Hrbek <kreyren@rixotstudio.cz> skribis:

> I am unable to define a guix shell file with shebang to decrease the complexity needed in the repository managing (so
> that i can just do ./path/to/guix.scm for guix to invoke `guix shell -f ./path/to/guix.scm` instead of having to
> sanitize the runtime) as the issue is that POSIX shebang allows only one argument and due to the way we handle
> reproducibility the shebang has to be `#!/usr/bin/env <command>`
>
> Proposing to integrate guix-shell for this purpose (inspired by NixOS) e.g.

This was briefly discussed here:

  https://issues.guix.gnu.org/50960#22

For now I use “#!/usr/bin/env -S guix shell --”, which works well enough
for me.  How does that sound?

Thanks,
Ludo’.


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

* Re: Unable to define shebang for guix shell file
  2021-11-09 17:21 ` Ludovic Courtès
@ 2021-11-09 21:35   ` Jacob Hrbek
  2021-11-09 22:14     ` Carlo Zancanaro
  0 siblings, 1 reply; 6+ messages in thread
From: Jacob Hrbek @ 2021-11-09 21:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 1256 bytes --]

> For now I use “#!/usr/bin/env -S guix shell --”, which works well enough for me.  How does that sound? -- ludo@gnu.org

Not a solution as (AFIAK) POSIX only accepts one argument.

-- Jacob "Kreyren" Hrbek

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Tuesday, November 9th, 2021 at 5:21 PM, Ludovic Courtès <ludo@gnu.org> wrote:

> Hi,
> 

> Jacob Hrbek kreyren@rixotstudio.cz skribis:
> 

> > I am unable to define a guix shell file with shebang to decrease the complexity needed in the repository managing (so
> > 

> > that i can just do ./path/to/guix.scm for guix to invoke `guix shell -f ./path/to/guix.scm` instead of having to
> > 

> > sanitize the runtime) as the issue is that POSIX shebang allows only one argument and due to the way we handle
> > 

> > reproducibility the shebang has to be `#!/usr/bin/env <command>`
> > 

> > Proposing to integrate guix-shell for this purpose (inspired by NixOS) e.g.
> 

> This was briefly discussed here:
> 

> https://issues.guix.gnu.org/50960#22
> 

> For now I use “#!/usr/bin/env -S guix shell --”, which works well enough
> 

> for me. How does that sound?
> 

> Thanks,
> 

> Ludo’.

[-- Attachment #1.2: publickey - kreyren@rixotstudio.cz - 0x1677DB82.asc --]
[-- Type: application/pgp-keys, Size: 737 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: Unable to define shebang for guix shell file
  2021-11-09 21:35   ` Jacob Hrbek
@ 2021-11-09 22:14     ` Carlo Zancanaro
  2021-11-09 22:34       ` Jacob Hrbek
  0 siblings, 1 reply; 6+ messages in thread
From: Carlo Zancanaro @ 2021-11-09 22:14 UTC (permalink / raw)
  To: Jacob Hrbek; +Cc: guix-devel

Hey Jacob,

On Tue, Nov 09 2021, Jacob Hrbek wrote:
>> For now I use “#!/usr/bin/env -S guix shell --”, which works 
>> well enough for me.  How does that sound? -- ludo@gnu.org
>
> Not a solution as (AFIAK) POSIX only accepts one argument.

That's the point of the -S. It passes the entire rest of the line 
as a single argument to /usr/bin/env, which reads it as a single 
-S argument which /usr/bin/env then interprets as a command with 
arguments.

Something like how this doesn't work:

  $ /usr/bin/env 'echo hello'
  /usr/bin/env: ‘echo hello’: No such file or directory
  /usr/bin/env: use -[v]S to pass options in shebang lines

But this does:

  $ /usr/bin/env '-S echo hello'
  hello

It looks like this was added to coreutils in 2018 in version 8.30. 
I wasn't aware of this feature until seeing Ludo's email, but it 
seems like a neat solution to the problem.

Carlo


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

* Re: Unable to define shebang for guix shell file
  2021-11-09 22:14     ` Carlo Zancanaro
@ 2021-11-09 22:34       ` Jacob Hrbek
  2021-11-17 10:51         ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Jacob Hrbek @ 2021-11-09 22:34 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 2584 bytes --]

Doesn't seem to work on `busybox sh` for me (I am not aware of better way to replicate POSIX environment on GNU Guix):

kreyren@leonid ~$ guix shell busybox -- busybox sh
...
~ $ cat test.sh 

#!/usr/bin/env -S guix shell --
(use-modules
	(guix channels))

(list (channel
        (name 'guix)
        (url "https://git.savannah.gnu.org/git/guix.git")
        (commit
          "f1bfd9f1948a5ff336d737c0614b9a30c2bb3097")
        (introduction
          (make-channel-introduction
            "9edb3f66fd807b096b48283debdcddccfea34bad"
            (openpgp-fingerprint
              "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))

(specifications->manifest
	(list "emacs@27.2"
		"emacs-treemacs"
		"emacs-evil"))
~ $ ./test.sh 

guix shell: warning: no packages specified; creating an empty environment
guix shell: warning: no packages specified; creating an empty environment
~ $ cat test.sh 

#!/usr/bin/env -S 'guix shell --'
...
~ $ ./test.sh 

/usr/bin/env: ‘guix shell --’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines
~ $ cat test.sh 

#!/usr/bin/env '-S guix shell --'
...
~ $ ./test.sh 

/usr/bin/env: ‘'-S guix shell --'’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

-- Jacob "Kreyren" Hrbek

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Tuesday, November 9th, 2021 at 10:14 PM, Carlo Zancanaro <carlo@zancanaro.id.au> wrote:

> Hey Jacob,
> 

> On Tue, Nov 09 2021, Jacob Hrbek wrote:
> 

> > > For now I use “#!/usr/bin/env -S guix shell --”, which works
> > > 

> > > well enough for me. How does that sound? -- ludo@gnu.org
> > 

> > Not a solution as (AFIAK) POSIX only accepts one argument.
> 

> That's the point of the -S. It passes the entire rest of the line
> 

> as a single argument to /usr/bin/env, which reads it as a single
> 

> -S argument which /usr/bin/env then interprets as a command with
> 

> arguments.
> 

> Something like how this doesn't work:
> 

> $ /usr/bin/env 'echo hello'
> 

> /usr/bin/env: ‘echo hello’: No such file or directory
> 

> /usr/bin/env: use -[v]S to pass options in shebang lines
> 

> But this does:
> 

> $ /usr/bin/env '-S echo hello'
> 

> hello
> 

> It looks like this was added to coreutils in 2018 in version 8.30.
> 

> I wasn't aware of this feature until seeing Ludo's email, but it
> 

> seems like a neat solution to the problem.
> 

> Carlo

[-- Attachment #1.2: publickey - kreyren@rixotstudio.cz - 0x1677DB82.asc --]
[-- Type: application/pgp-keys, Size: 737 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

* Re: Unable to define shebang for guix shell file
  2021-11-09 22:34       ` Jacob Hrbek
@ 2021-11-17 10:51         ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2021-11-17 10:51 UTC (permalink / raw)
  To: Jacob Hrbek; +Cc: guix-devel

Hi,

Jacob Hrbek <kreyren@rixotstudio.cz> skribis:

> Doesn't seem to work on `busybox sh` for me (I am not aware of better way to replicate POSIX environment on GNU Guix):

Note that you’re running /usr/bin/env, which has nothing to do with
Busybox.

> kreyren@leonid ~$ guix shell busybox -- busybox sh
> ...
> ~ $ cat test.sh 
>
> #!/usr/bin/env -S guix shell --
> (use-modules
> 	(guix channels))
>
> (list (channel
>         (name 'guix)
>         (url "https://git.savannah.gnu.org/git/guix.git")
>         (commit
>           "f1bfd9f1948a5ff336d737c0614b9a30c2bb3097")
>         (introduction
>           (make-channel-introduction
>             "9edb3f66fd807b096b48283debdcddccfea34bad"
>             (openpgp-fingerprint
>               "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))
>
> (specifications->manifest
> 	(list "emacs@27.2"
> 		"emacs-treemacs"
> 		"emacs-evil"))
> ~ $ ./test.sh 
>
> guix shell: warning: no packages specified; creating an empty environment
> guix shell: warning: no packages specified; creating an empty environment

It’s working as expected: ‘guix shell’ has zero arguments so it creates
an empty environment.  Additionally, the shebang does not specify an
interpreter.

The example I gave at <https://issues.guix.gnu.org/50960#22> goes like
this:

--8<---------------cut here---------------start------------->8---
$ cat t.sh
#!/usr/bin/env -S guix shell hello bash -- sh
type -P hello
hello
--8<---------------cut here---------------end--------------->8---

HTH!

Ludo’.


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

end of thread, other threads:[~2021-11-17 10:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01  0:08 Unable to define shebang for guix shell file Jacob Hrbek
2021-11-09 17:21 ` Ludovic Courtès
2021-11-09 21:35   ` Jacob Hrbek
2021-11-09 22:14     ` Carlo Zancanaro
2021-11-09 22:34       ` Jacob Hrbek
2021-11-17 10:51         ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).