From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Gibbons Subject: Re: Scripting guix in guile Date: Sun, 01 Sep 2019 08:24:13 -0600 Message-ID: References: <1909d3ec18a961a8d957d677e27fdcc05dd8608c.camel@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:39810) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i4Qm9-0006Q5-Oo for help-guix@gnu.org; Sun, 01 Sep 2019 10:24:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i4Qm8-0008IW-Eb for help-guix@gnu.org; Sun, 01 Sep 2019 10:24:17 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:43374) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i4Qm8-0008Hz-8p for help-guix@gnu.org; Sun, 01 Sep 2019 10:24:16 -0400 Received: by mail-pf1-x42c.google.com with SMTP id v12so7362447pfn.10 for ; Sun, 01 Sep 2019 07:24:16 -0700 (PDT) In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Konrad Hinsen , help-guix@gnu.org 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 > patching > my script. But that comes at a significant cost in terms of > deployment > complexity. It's certainly the right way to distribute black-box > tools, > but my scripts are mainly illustrations for working with Guix. I want > to > use them in a tutorial, saying "there is no built-in Guix > functionality > 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 to this: 1. Tell your audience to call "guile " 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 script: - guix build --source 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 will put everything the package needs into a shell environment. - guix pack 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 anything. > > > 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 GUILE_LOAD_PATH. > > --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 > report > back! > > Konrad.