From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Gibbons Subject: Re: Scripting guix in guile Date: Sat, 31 Aug 2019 11:38:03 -0600 Message-ID: <1909d3ec18a961a8d957d677e27fdcc05dd8608c.camel@gmail.com> References: 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]:40263) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i47KB-0005os-ED for help-guix@gnu.org; Sat, 31 Aug 2019 13:38:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i47KA-0003ZH-8k for help-guix@gnu.org; Sat, 31 Aug 2019 13:38:07 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:35554) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i47KA-0003Z1-3N for help-guix@gnu.org; Sat, 31 Aug 2019 13:38:06 -0400 Received: by mail-pg1-x534.google.com with SMTP id n4so5158260pgv.2 for ; Sat, 31 Aug 2019 10:38:06 -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 Sat, 2019-08-31 at 19:03 +0200, Konrad Hinsen wrote: > Hi everyone, > > I'd like to write Guile scripts that inspect Guix, for example > analyze > the packages is my profile. That turned out to be a lot more > difficult > than I expected, and in fact I haven't found a satisfying general > solution yet, meaning a script that I could publish in such a way > that > any Guix user could download and run it without modification. > > The problems I see are > > 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. > 2. How to construct the load path to make sure it includes > Guix as installed under $HOME/.config/guix/current I think the default GUILE_LOAD_PATH includes guix. Here's the contents of mine: ~$ ls $GUILE_LOAD_PATH bytestructures git.scm gnutls guix.scm json.scm shepherd.scm gcrypt gnu gnutls.scm ice-9/ mcron sqlite3.scm git gnu.scm guix json shepherd ssh gnu/, gnu.scm, guix/, and guix.scm are all guix, and guix is not part of my current profile. Note also most of these are prerequisites for guix. > > I wonder if could somehow hijack 'guix repl', which solves these > problems for a REPL but not for scripts. > > Any ideas? > > Konrad > -You're writing tools for a package manager... try packaging those tools for the package manager. It will take care of them like it takes care of everything else. --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.