guix-devel
[Top][All Lists]
Advanced

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

Re: Installing a wrapper guile script in <out>/bin


From: Maxime Devos
Subject: Re: Installing a wrapper guile script in <out>/bin
Date: Wed, 03 Feb 2021 13:12:25 +0100
User-agent: Evolution 3.34.2

> The script contents are not what I'm confused about. I don't know how to turn
> my gexp script into a file under <out>/bin/. This is conceptually what I want:
> 
>     (package
>       (name "foo")
>       ...
>       (arguments
>        `(...
>          #:phases
>          (modify-phases %standard-phases
>          ...
>          (replace 'install
>            (lambda* (#:key outputs #:allow-other-keys)
>              (let ((out (assoc-ref outputs "out"))
>                    (wrapper-script #~(...)))
>              ... ; Do normal install stuff
>              (copy-file wrapper-script (string-append out "/bin/foo"))
>              ... ; Finish install stuff
>              )))))))
> 
> Of course `copy-file` doesn't work here because `wrapper-script` is a gexp not
> a file. What code do I replace this with?

Three options I have in mind:

* forego representing `wrapper-script` as a gexp (using #~), instead represent
  `wrapper-script` as something quasiquoted.  Then write this expression to
  a file (with 'write', and include an appropriate shebang line)

  Something like this:

  (let ((wrapper-script-contents `(exec* ,(string-append out "/bin/.foo-real") 
"--extra-library-stuff" other-arguments)))
    rename-upstream-binary
    write-wrapper-binary
  )

* The procedure ‘program-file’ turns a gexp into a representation of a store 
item.

  Write your script to accept arguments like this:
  YOUR-SCRIPT REAL-BINARY ARGUMENTS
  
  And write a small wrapper shell script to <out>/bin/foo. Maybe with something 
like this
  (format PORT "#!~a~%exec ~a ~a #$@" bin-sh-something #$THE-SCRIPT-GEXP 
<out>/bin/.foo-real)

  (Warning: the above shell script might be incorrect.  I'm not very familiar
  with using the shell as a programming language.)

* Define a wrapper package.  See wrap-python3 in packages/python.scm
  for an example. (This option probably has to be combined with one of the
  first two options.) 

Greetings,
Maxime

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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