From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yE/NH09i7151HQAA0tVLHw (envelope-from ) for ; Sun, 21 Jun 2020 13:36:15 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wFSYG09i717kGAAA1q6Kng (envelope-from ) for ; Sun, 21 Jun 2020 13:36:15 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EA94C94053C for ; Sun, 21 Jun 2020 13:36:14 +0000 (UTC) Received: from localhost ([::1]:45228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jn08r-0004pN-UI for larch@yhetil.org; Sun, 21 Jun 2020 09:36:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jn08g-0004or-TB for guix-patches@gnu.org; Sun, 21 Jun 2020 09:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jn08g-0000aZ-J5 for guix-patches@gnu.org; Sun, 21 Jun 2020 09:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jn08g-000451-GI for guix-patches@gnu.org; Sun, 21 Jun 2020 09:36:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41980] [PATCH] rshiny service Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 21 Jun 2020 13:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41980 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41980@debbugs.gnu.org Cc: Ricardo Wurmus Received: via spool by 41980-submit@debbugs.gnu.org id=B41980.159274651215601 (code B ref 41980); Sun, 21 Jun 2020 13:36:02 +0000 Received: (at 41980) by debbugs.gnu.org; 21 Jun 2020 13:35:12 +0000 Received: from localhost ([127.0.0.1]:59354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jn07o-00043V-P6 for submit@debbugs.gnu.org; Sun, 21 Jun 2020 09:35:12 -0400 Received: from flashner.co.il ([178.62.234.194]:53986) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jn07i-00042r-ND for 41980@debbugs.gnu.org; Sun, 21 Jun 2020 09:35:06 -0400 Received: from localhost (unknown [31.210.181.184]) by flashner.co.il (Postfix) with ESMTPSA id CA6EF4000B; Sun, 21 Jun 2020 13:34:56 +0000 (UTC) Date: Sun, 21 Jun 2020 16:34:24 +0300 From: Efraim Flashner Message-ID: <20200621133424.GB22974@E5400> References: <20200621133112.GA22974@E5400> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="V88s5gaDVPzZ0KCq" Content-Disposition: inline In-Reply-To: <20200621133112.GA22974@E5400> X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -2.61 X-TUID: FIXNRWTWk5X9 --V88s5gaDVPzZ0KCq Content-Type: multipart/mixed; boundary="98e8jtXdkpgskNou" Content-Disposition: inline --98e8jtXdkpgskNou Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jun 21, 2020 at 04:31:12PM +0300, Efraim Flashner wrote: > I created this for Pjotr but Ricardo said he was interested in a shiny > service too so I figured I'd see about documenting it. Currently we > don't have any packages in Guix which would work with this so I have a > link=C2=B9 to one. I'm not sure if this fits well in Guix or if I should = keep > it in the guix-bioinformatics channel. >=20 > I feel like the documentation as I've written it so far is weak. Also, > I've tried to run it inside a make-forkexec-command/container Guix > Service but I ran into problems, as I documented elsewhere=C2=B2. >=20 >=20 > =C2=B9 http://git.genenetwork.org/guix-bioinformatics/guix-bioinformatics= /src/branch/master/gn/packages/bioinformatics.scm#L716 > =C2=B2 http://git.genenetwork.org/guix-bioinformatics/guix-bioinformatics= /src/branch/master/gn/services/rshiny.scm#L41 >=20 And of course I forgot to attach the patch ... --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --98e8jtXdkpgskNou Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-services-Add-rshiny-service.patch" Content-Transfer-Encoding: quoted-printable =46rom 88567daa3e9d952e1723078ef13b088ef111b1bd Mon Sep 17 00:00:00 2001 =46rom: Efraim Flashner Date: Sun, 21 Jun 2020 16:20:16 +0300 Subject: [PATCH] services: Add rshiny service. * gnu/services/science.scm: New file. (): New record. (rshiny-shepherd-service-type): New variable. * doc/guix.texi (Miscellaneous Services): Document it. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- doc/guix.texi | 49 ++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + gnu/services/science.scm | 57 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 gnu/services/science.scm diff --git a/doc/guix.texi b/doc/guix.texi index 5b854ccbd4..996122483d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -26612,6 +26612,55 @@ setuid-root (@pxref{Setuid Programs}) such that un= privileged users can invoke @command{singularity run} and similar commands. @end defvr =20 +@cindex rshiny +@subsubheading R-Shiny service + +The @code{(gnu services science)} module provides the following service. + +@defvr {Scheme Variable} rshiny-service-type + +This is a type of service which is used to run a webapp created with +@code{r-shiny}. This service sets the @code{R_LIBS_USER} environment +variable and runs the provided script to call @code{runApp}. + +@deftp {Data Type} rshiny-configuration +This is the data type representing the configuration of rshiny. + +@table @asis + +@item @code{package} (default: @code{r-shiny}) +The package to use. + +@item @code{binary} (defaunlt @code{"rshiny"}) +The name of the binary or shell script located at @code{package/bin/} to +run when the service is run. + +The common way to create this file is as follows: + +@lisp +@dots{} +(let* ((out (assoc-ref %outputs "out")) + (targetdir (string-append out "/share/" ,name)) + (app (string-append out "/bin/" ,name)) + (Rbin (string-append (assoc-ref %build-inputs "r-min") + "/bin/Rscript"))) +@dots{} + (mkdir-p (string-append out "/bin")) + (call-with-output-file app + (lambda (port) + (format port +"#!~a +library(shiny) +setwd(\"~a\") +runApp(launch.browser=3D0, port=3D4202)~%\n" + Rbin targetdir))) +@dots{} +@end lisp + +@end table +@end deftp +@end defvr + @cindex Nix @subsubheading Nix service =20 diff --git a/gnu/local.mk b/gnu/local.mk index 347d4bbb17..6b76500172 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -597,6 +597,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/services/nix.scm \ %D%/services/nfs.scm \ %D%/services/pam-mount.scm \ + %D%/services/science.scm \ %D%/services/security-token.scm \ %D%/services/shepherd.scm \ %D%/services/sound.scm \ diff --git a/gnu/services/science.scm b/gnu/services/science.scm new file mode 100644 index 0000000000..94ff0f36f2 --- /dev/null +++ b/gnu/services/science.scm @@ -0,0 +1,57 @@ +(define-module (gnu services science) + #:export ( + rshiny-configuration + rshiny-configuration? + rshiny-configuration-package + rshiny-configuration-binary + rshiny-shepherd-service + rshiny-service-type)) + +(use-modules (gnu) + (guix records) + (ice-9 match)) +(use-service-modules shepherd) +(use-package-modules cran) + +(define-record-type* + rshiny-configuration + make-rshiny-configuration + rshiny-configuration? + (package rshiny-configuration-package ; package + (default r-shiny)) + (binary rshiny-configuration-binary ; string + (default "rshiny"))) + +(define rshiny-shepherd-service + (match-lambda + (($ package binary) + (list + (shepherd-service + (documentation (string-append "R-Shiny service for " binary)) + (provision (list (symbol-append 'rshiny- (string->symbol + (string-take binary 9)= )))) + (requirement '(networking)) + (start + #~(exec-command + (list + #$(string-append "/run/current-system/profile/bin/" binar= y)) + ;#:log-file #$(string-append "/var/log/" binary ".log") ; k= ills shepherd + #:environment-variables + (list "R_LIBS_USER=3D/run/current-system/profile/site-libra= ry/"))) + (stop #~(make-kill-destructor))))))) + +(define rshiny-service-type + (service-type + (name 'rshiny) + (extensions + (list + (service-extension shepherd-root-service-type + rshiny-shepherd-service) + (service-extension profile-service-type + ;; We want the package installed so that it + ;; pulls in the propagated inputs as well. + (lambda (config) + (list + (rshiny-configuration-package config)))))) + (description + "Run an R-Shiny webapp as a Guix Service."))) --=20 2.26.2 --98e8jtXdkpgskNou-- --V88s5gaDVPzZ0KCq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl7vYeAACgkQQarn3Mo9 g1H2uBAAnE2QUxOgfsqTActYHt6Mzv8FL5YZSd21ZWKwxqbyPKj5DU2eekzUbpNF Z2nUl1bmEfc75x8UKuIcAM5n/lTeb+dCGl+STSFjwSH5x7mYxm9Z1k/aoH9fYv4S GVY1qdc3wSbGyvFfsNDZLoFz6kaMIRsS0C0eZHn+F+3QRnJyWAsJqC5ZkiM6K7Lw ZYC95CnOF1i5bSRr218WWzszg5mec3ZP/quu4U5k9uGWU7huI2nJpA8QqQBZmqgF BMid5snae/f9WlqnaHtt5+jPa2YkUCoL+p4GBDjpwo5vTfahrAflqWkCol6wU0Vd WkeJ8ZwNEvvV7JO8oMXbnom3OVej+IkAEWMMl4+3VCZo6N8gc31OD70VI3s9+BJT uoAZ/IpdopJOTT0z2iQlZ7YyvIraq4VK5Sa+E4hH3IXvNctdbCvcRsUatWBG8/Wx y/xeOWQJt6T+t0j607BHiEG6Pwib/G+N/izaAk0y/iEJZYOujiiyA/Fa0F9VHBu0 waWsrSq4cXnPScS8LiESkDY6MQ4WzdhAaEPBq9Gt9EwGhc6VaTjbrTvcE6d7jMSH 9g5FfJM3hbKmtJK8eSu5R4DsafklMN/KYMoXRAjcwqZRD06mtcPk2COjqSfQoWEc by+HCUWGk5zHGhn/2Vc3l8pUy5JmWttqdeLh1V99g8KSxfaCuys= =Ymbh -----END PGP SIGNATURE----- --V88s5gaDVPzZ0KCq--