[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make a simple guile script to a package - source local file
From: |
Théo Tyburn |
Subject: |
Re: Make a simple guile script to a package - source local file |
Date: |
Sat, 20 Jan 2024 18:05:19 +0000 |
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