Dear all,
Some Python packages are both libraries and applications, like pylint.
Using the library requires installing python: `guix shell --container
python-pylint -- python3` does not work (instead the user should do
`guix shell --container python python-pylint -- python3`). On the other
hand, using the application does not require installing python: `guix
shell --container python-pylint -- pylint --version` does work.
How should one make an R package that is both a library and an
application (for example, a Shiny application) behave likewise? Using
the library should require installing R: `guix shell r-myrpackage --
R` should not work (instead the user should do `guix shell r-minimal
r-myrpackage -- R`). On the other hand, using the application should
not require installing R: `guix shell r-myrpackage -- myprogram` should
work. Is the following correct?
```
(use-modules (gnu)
(guix build-system r)
(guix gexp)
((guix licenses) #:prefix license:)
(guix packages))
(use-package-modules cran statistics)
(package
(name "r-myrpackage")
(version "1.0.0")
(source (local-file "." "myrpackage" #:recursive? #t))
(properties '((upstream-name . "myrpackage")))
(build-system r-build-system)
(arguments (list #:phases #~(modify-phases %standard-phases
(add-after 'install 'install-script
(lambda _
(let ((bin (in-vicinity #$output "bin")))
(install-file "myprogram" bin)
(wrap-program
(in-vicinity bin "myprogram")
`("R_LIBS_SITE"
":"
=
(,(getenv "R_LIBS_SITE"))))))))))
(inputs (list r-minimal))
(propagated-inputs (list r-shiny))
(home-page "https://example.com")
(synopsis "Blah blah blah")
(description "Blah blah blah.")
(license license:agpl3))
```
The script `myprogram` is as follows.
```
#!/usr/bin/env Rscript
myrpackage::my_function()
```
It appears to work, but I am not sure if it is correct or best practice,
especially the part `(wrap-program ...)` to ensure that when the script
`myprogram` is executed Rscript can find the R package `myrpackage`.
Yours faithfully,
JD