guile-web.scm 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
  3. ;;; Copyright © 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
  5. ;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
  6. ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
  7. ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
  8. ;;;
  9. ;;; This file is part of GNU Guix.
  10. ;;;
  11. ;;; GNU Guix is free software; you can redistribute it and/or modify
  12. ;;; it under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation, either version 3 of the License, or
  14. ;;; (at your option) any later version.
  15. ;;;
  16. ;;; GNU Guix is distributed in the hope that it will be useful,
  17. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (guile-web)
  24. #:use-module (guix gexp)
  25. #:use-module (guix records)
  26. #:use-module (gnu packages admin)
  27. ;; #:autoload (gnu packages ci) (cuirass)
  28. ;; #:autoload (gnu packages version-control) (git)
  29. #:use-module (gnu services)
  30. #:use-module (gnu services base)
  31. #:use-module (gnu services shepherd)
  32. #:use-module (gnu services admin)
  33. #:use-module (gnu system shadow)
  34. #:export (<guile-web-configuration>
  35. guile-web-configuration
  36. guile-web-configuration?
  37. guile-web-service-type
  38. ;; a user on irc said I probably do not need to export the
  39. ;; user or group.
  40. ;;user
  41. ;;group
  42. ))
  43. ;;;; Commentary:
  44. ;;; This file provides a shepherd service to run my homebrewed version
  45. ;;; of a website. ~/prog/guile/web/web.scm
  46. ;;;; Code:
  47. (define-record-type* <guile-web-configuration>
  48. guile-web-configuration make-guile-web-configuration
  49. guile-web-configuration?
  50. (guile guile-web-configuration-guile ;;package:
  51. (default guile)) ;;guile-2.0
  52. (user guile-web-configuration-user ;string
  53. (default "joshua"))
  54. (group guile-web-configuration-group ;string
  55. (default "joshua")))
  56. (define (guile-web-shepherd-service config)
  57. "Return a <shepherd-service> for the Guile-Web service."
  58. (let ((guile guile-web-configuration-guile)
  59. (user guile-web-configuration-user)
  60. (group guile-web-configuration-group))
  61. (list (shepherd-service
  62. (documentation "Run the guile web site that I made.")
  63. (provision '(guile-web))
  64. (requirement '(networking))
  65. (start #~(make-forkexec-constructor
  66. (list (string-append #$guile "/bin/guile")
  67. "/home/joshua/prog/guile/web/web.scm")
  68. ;; #:environment-variables
  69. ;; (list "GPG_TTY=$(tty)")
  70. #:user #$user
  71. #:group #$group
  72. ))
  73. (stop #~(make-kill-destructor))))))
  74. ;; <leoprikler> guile-web-service-type should extend shepherd-service,
  75. ;;passing guile-web-shepherd service <leoprikler> inside your shepherd service check whether the field names are
  76. ;;actually correct [18:49]
  77. (define-public guile-web-service-type
  78. (service-type
  79. (name 'guile-web)
  80. (description "Run the program ~/prog/guile/web.scm")
  81. (extensions
  82. (list
  83. ;; (service-extension profile-service-type ;for 'info guile'
  84. ;; (compose list guile-web-configuration-guile))
  85. (service-extension shepherd-service guile-web-shepherd-service)
  86. ;; I could also use shepherd-root-service-type ???
  87. ;;(service-extension shepherd-service guile-web-service)
  88. )
  89. )
  90. (default-value (guile-web-configuration))
  91. ))
  92. (display "I am displaying guile web service type\n")
  93. (display guile-web-service-type)
  94. (display "\n")