help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simplest package definition?


From: John J Foerch
Subject: Re: simplest package definition?
Date: Thu, 25 Aug 2016 09:42:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Alex Kost <address@hidden> writes:

> 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)))

Thank you so much, this is incredibly helpful, both for doing some odds
and ends that I want to do with my guix system, but also for
understanding packaging better.

--
John Foerch




reply via email to

[Prev in Thread] Current Thread [Next in Thread]