On 2024-01-20 12:32:08 +0000, Théo Tyburn wrote: > Richard Sent 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.