From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: simplest package definition? Date: Thu, 25 Aug 2016 11:52:46 +0300 Message-ID: <87bn0hb57l.fsf@gmail.com> References: <87fuptslku.fsf@hecubus.retroj.net> <87fuptb6qc.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcqP4-0002tF-PQ for help-guix@gnu.org; Thu, 25 Aug 2016 04:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcqOz-0000PG-QQ for help-guix@gnu.org; Thu, 25 Aug 2016 04:52:49 -0400 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]:34857) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcqOz-0000P0-Hu for help-guix@gnu.org; Thu, 25 Aug 2016 04:52:45 -0400 Received: by mail-lf0-x234.google.com with SMTP id f93so29732637lfi.2 for ; Thu, 25 Aug 2016 01:52:45 -0700 (PDT) In-Reply-To: <87fuptb6qc.fsf@gmail.com> (Alex Kost's message of "Thu, 25 Aug 2016 11:19:55 +0300") 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: John J Foerch Cc: help-guix@gnu.org Alex Kost (2016-08-25 11:19 +0300) wrote: > John J Foerch (2016-08-25 04:07 +0300) wrote: > >> Hello Guix, >> >> What is the simplest possible package definition, to install a single >> shell script? If possible, I would like to install it from the >> directory in which I'm developing it, and the package definition would >> also be in a file in this directory. > > So you have some dir and 2 files there: "my-shell-script" and > "guix.scm", right? If you don't care about shebang (I mean if you have > "#!/bin/sh" in the script, it will not be changed to > /gnu/store/.../bash), then you can use trivial-build-system. I've found how to patch shebang staying inside trivial-build-system. There is 'patch-shebang' procedure in (guix build utils) module, so all is needed is to call it with the proper path (containing bash or another shell you use). So the following lines should be added: > (use-modules (gnu packages bash) > (guix gexp) > (guix packages) > (guix build-system trivial)) > > (let ((script-name "my-shell-script")) > (package > (name script-name) > (version "0.1") > (source (local-file (string-append (dirname (current-filename)) > "/" script-name))) > (build-system trivial-build-system) > (arguments > `(#:modules ((guix build utils)) > #:builder > (begin > (use-modules (guix build utils)) > (let* ((bin-dir (string-append %output "/bin")) > (bin-file (string-append bin-dir "/" ,script-name))) Add inside 'let': (bash-bin (string-append (assoc-ref %build-inputs "bash") "/bin")) > (mkdir-p bin-dir) > (copy-file (assoc-ref %build-inputs "source") bin-file) (patch-shebang bin-file (list bash-bin)) > (chmod bin-file #o555))))) (inputs `(("bash" ,bash))) > (home-page #f) > (synopsis "bla bla") > (description "More verbose bla bla") > (license #f))) -- Alex