all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* simplest package definition?
@ 2016-08-25  1:07 John J Foerch
  2016-08-25  8:19 ` Alex Kost
  0 siblings, 1 reply; 5+ messages in thread
From: John J Foerch @ 2016-08-25  1:07 UTC (permalink / raw)
  To: help-guix

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.

Thank you,

--
John Foerch

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest package definition?
  2016-08-25  1:07 simplest package definition? John J Foerch
@ 2016-08-25  8:19 ` Alex Kost
  2016-08-25  8:52   ` Alex Kost
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Kost @ 2016-08-25  8:19 UTC (permalink / raw)
  To: John J Foerch; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

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.  So the
contents of "guix.scm" can be:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: guix-script-test.scm --]
[-- Type: text/x-scheme, Size: 824 bytes --]

(use-modules
 (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)))
           (mkdir-p bin-dir)
           (copy-file (assoc-ref %build-inputs "source") bin-file)
           (chmod bin-file #o555)))))
    (home-page #f)
    (synopsis "bla bla")
    (description "More verbose bla bla")
    (license #f)))

[-- Attachment #3: Type: text/plain, Size: 244 bytes --]


Use "guix build -f .../guix.scm" to build it.

If you care about shebang, I think you need to use gnu-build-system
(there is a phase that patches shebangs), but it requires removing many
phases and probably some additional tweaking.

-- 
Alex

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest package definition?
  2016-08-25  8:19 ` Alex Kost
@ 2016-08-25  8:52   ` Alex Kost
  2016-08-25  9:03     ` Vincent Legoll
  2016-08-25 13:42     ` John J Foerch
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Kost @ 2016-08-25  8:52 UTC (permalink / raw)
  To: John J Foerch; +Cc: help-guix

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest package definition?
  2016-08-25  8:52   ` Alex Kost
@ 2016-08-25  9:03     ` Vincent Legoll
  2016-08-25 13:42     ` John J Foerch
  1 sibling, 0 replies; 5+ messages in thread
From: Vincent Legoll @ 2016-08-25  9:03 UTC (permalink / raw)
  To: Alex Kost; +Cc: help-guix, John J Foerch

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

I think you can also use "which" to find bash if you don't want to add
it to your inputs.

(let ((sh (which "sh"))) ...)

But I don't know which solution is better...

-- 
Vincent Legoll

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: simplest package definition?
  2016-08-25  8:52   ` Alex Kost
  2016-08-25  9:03     ` Vincent Legoll
@ 2016-08-25 13:42     ` John J Foerch
  1 sibling, 0 replies; 5+ messages in thread
From: John J Foerch @ 2016-08-25 13:42 UTC (permalink / raw)
  To: help-guix

Alex Kost <alezost@gmail.com> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-25 13:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-25  1:07 simplest package definition? John J Foerch
2016-08-25  8:19 ` Alex Kost
2016-08-25  8:52   ` Alex Kost
2016-08-25  9:03     ` Vincent Legoll
2016-08-25 13:42     ` John J Foerch

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.