From: "Théo Tyburn" <theo.tyburn@posteo.net>
To: Tomas Volf <~@wolfsden.cz>
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 18:05:19 +0000 [thread overview]
Message-ID: <87cytvj2ii.fsf@posteo.net> (raw)
In-Reply-To: <ZavKwr0dAAlq6BRD@ws>
Tomas Volf <~@wolfsden.cz> writes:
> [[PGP Signed Part:Undecided]]
> 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
Sure it is faster on the second run. Although it is even faster to
activate a profile. At least for me. Maybe this is getting slowed down
because I have some personal guile in $GUILE_LOAD_PATH ? I get something
like this even after having run the command already:
$ time -p guix shell vim -- true
real 1.52
user 2.06
sys 0.15
>> > 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).
Interesting. Also good to know, thanks
prev parent reply other threads:[~2024-01-20 18:15 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
2024-01-20 18:05 ` Théo Tyburn [this message]
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=87cytvj2ii.fsf@posteo.net \
--to=theo.tyburn@posteo.net \
--cc=help-guix@gnu.org \
--cc=richard@freakingpenguin.com \
--cc=~@wolfsden.cz \
/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).