1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu services science)
20 #:export (<rshiny-configuration>
23 rshiny-configuration-package
24 rshiny-configuration-binary
25 rshiny-shepherd-service
31 (use-service-modules shepherd)
32 (use-package-modules cran)
34 (define-record-type* <rshiny-configuration>
36 make-rshiny-configuration
38 (package rshiny-configuration-package ; file-like
40 (binary rshiny-configuration-binary ; string
43 (define rshiny-shepherd-service
45 (($ <rshiny-configuration> package binary)
48 (documentation (string-append "R-Shiny service for " binary))
49 (provision (list (symbol-append 'rshiny- (string->symbol
50 (string-take binary 9)))))
51 (requirement '(networking))
55 #$(string-append "/run/current-system/profile/bin/" binary))
56 ;#:log-file #$(string-append "/var/log/" binary ".log") ; kills shepherd
57 #:environment-variables
58 (list "R_LIBS_USER=/run/current-system/profile/site-library/")))
59 (stop #~(make-kill-destructor)))))))
61 (define rshiny-service-type
66 (service-extension shepherd-root-service-type
67 rshiny-shepherd-service)
68 (service-extension profile-service-type
69 ;; We want the package installed so that it
70 ;; pulls in the propagated inputs as well.
73 (rshiny-configuration-package config))))))
75 "Run an R-Shiny webapp as a Guix Service.")))