unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Tomas Volf <~@wolfsden.cz>
To: "Théo Tyburn" <theo.tyburn@posteo.net>
Cc: Richard Sent <richard@freakingpenguin.com>, help-guix@gnu.org
Subject: Re: Make a simple guile script to a package - source local file
Date: Sat, 20 Jan 2024 14:29:38 +0100	[thread overview]
Message-ID: <ZavKwr0dAAlq6BRD@ws> (raw)
In-Reply-To: <87frysi3fz.fsf@posteo.net>

[-- Attachment #1: Type: text/plain, Size: 2371 bytes --]

On 2024-01-20 12:32:08 +0000, Théo Tyburn wrote:
> Richard Sent <richard@freakingpenguin.com> writes:
> 
> > Depending on what you mean by polluting or re-entering the profile
> > information all the time this might not be what you want. When I write
> > scripts that rely on specific dependencies I don't want to permanently
> > install, I write the shebang like this:
> >
> > --8<---------------cut here---------------start------------->8---
> > #!/usr/bin/env -S guix shell ruby ruby-colorize password-store -- ruby
> > --8<---------------cut here---------------end--------------->8---
> 
> This is a really nice trick !
> 
> Unfortunately you either have to reevaluate the profile at each
> run or create a profile and do something like
> 
> #!/usr/bin/env -S guix shell -p
>   ${GUIX_EXTRA_PROFILES}/python-pydbus/python-pydbus -- python3

It is work nothing that guix shell does cache the profiles, so it is pretty
fast:

    $ time -p guix shell vim -- true
    The following derivation will be built:
      /gnu/store/4mlf31h32244xzcni9w43f95k8n8xf1h-profile.drv
    
    applying 3 grafts for tcsh-6.24.01 ...
    applying 7 grafts for vim-9.0.2001 ...
    building CA certificate bundle...
    listing Emacs sub-directories...
    building fonts directory...
    building directory of Info manuals...
    building profile with 1 package...
    real 2.28
    user 1.24
    sys 0.09
    $ time -p guix shell vim -- true
    real 0.11
    user 0.14
    sys 0.01
    $ time -p guix shell vim -- true
    real 0.11
    user 0.13
    sys 0.02

> 
> > This relies on /usr/bin/env supporting -S, which to my understanding
> > isn't POSIX but instead a coreutils extension. Pretty sure --container
> > would work here but I've not tried it.
> 
> Also as you mentioned, I fear I will not be able to directly
> distribute this to people not running guix.
> 
> But thanks for the hint :)

I am using (for guile scripts) something like:

  #!/bin/sh
  exec guix shell ... -- guile -e main -s "$0" "$@"

So if the language allows you to treat the first non-shebang line as a shell
script, you can suddenly get by with POSIX env (which is handy on alpine linux).

Have a nice day,
Tomas Volf

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-01-20 14:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 18:01 Make a simple guile script to a package - source local file Théo Tyburn
2023-10-26 14:18 ` Tomas Volf
2023-10-29  8:44   ` Théo Tyburn
2024-01-19 21:28   ` Théo Tyburn
2024-01-19 21:46     ` Felix Lechner via
2024-01-20 17:19       ` Théo Tyburn
2024-01-19 22:44     ` Richard Sent
2024-01-20 12:32       ` Théo Tyburn
2024-01-20 13:29         ` Tomas Volf [this message]
2024-01-20 18:05           ` Théo Tyburn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZavKwr0dAAlq6BRD@ws \
    --to=~@wolfsden.cz \
    --cc=help-guix@gnu.org \
    --cc=richard@freakingpenguin.com \
    --cc=theo.tyburn@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).