[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scripting guix in guile
Re: Scripting guix in guile
Sun, 01 Sep 2019 08:24:13 -0600
On Sun, 2019-09-01 at 10:15 +0200, Konrad Hinsen wrote:
> Hi Jesse,
> First of all, thanks for your suggestions!
> > > 1. What to put into the #! line to locate Guile.
> > I don't think you need a shebang to script guile. If you do, you
> > could
> > always make a guix package for the scripts, and that will fix
> > everything in the patch-shebangs phase.
> Right, packaging solves the problem because Guix takes care of
> my script. But that comes at a significant cost in terms of
> complexity. It's certainly the right way to distribute black-box
> but my scripts are mainly illustrations for working with Guix. I want
> use them in a tutorial, saying "there is no built-in Guix
> for this, but you can write your own scripts interfacing with
> Guix. Here's an example, download it, play with it, modify it to fit
> your needs."
I'm don't know if there's a way to run raw scripts by themselves in
guixsd without patching the shebangs. I currently have three solutions
1. Tell your audience to call "guile <scriptname>" when running the
script. This does not garuntee guix is in their GUILE_LOAD_PATH though, so you
will either need to tell them to add a segment to .bashrc to add the guix
source location to their GUILE_LOAD_PATH or have them use the -L flag to have
guile search that directory.
2. Instruct the audience to use features of guix when playing with the
- guix build --source <packagename> can download the source into a
tarball (if it is a tarball) or a directory (if it is in a git repo).
If it is successful, it will output where the source is to stdout. If
the source is in a directory, you will need to copy it and chown the
copy before you can edit it.
- guix environment <packagename> will put everything the package needs
into a shell environment.
- guix pack <packagename> builds a tarball of the package with its
dependencies. If it is successful it will output where the tarball is
in the store to stdout.
- the --root= option of guix build --source and guix pack will make a soft link
to the resulting tarball or directory in the specified location. - the
--with-source=PACKAGE=SOURCE option can specify where the source is, so if you
have local source you can specify its root directory.
3. I think you can use autogen to find out where guile and guix are
located and use that location in the shebang and in a script that adds
guix to GUILE_LOAD_PATH. This is a bit complicated though, and you will
need to make sure your audience has autogen before they can do
> > I think the default GUILE_LOAD_PATH includes guix. Here's the
> > contents
> Not on my system. I am using Guix on top of Ubuntu, maybe for Guix
> System it works out of the box. I'll try with a virtual machine.
If you package your scripts, you can specify guix as an input. I think
that will either put guix in the GUILE_LOAD_PATH or instruct whoever
installs it to add a snippet to .bashrc that puts guix in
> > --You can wrap the executables with the environment variables you
> > need
> > so the executable scripts are callable from the default PATH. See
> > what
> > guix does with guile, mcron, and shepherd, which are mostly guile
> > scripts with a little bit of native code.
> Looking at those examples is certainly a good plan - I'll do and