hurd.scm 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  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.
  10. ;;;
  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.
  15. ;;;
  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/>.
  18. (define-module (gnu services hurd)
  19. #:use-module (gnu packages admin)
  20. #:use-module (gnu packages hurd)
  21. #:use-module (gnu services)
  22. #:use-module (gnu services shepherd)
  23. #:use-module (gnu system)
  24. #:use-module (guix gexp)
  25. #:use-module (guix records)
  26. #:export (hurd-console-configuration
  27. hurd-console-service-type
  28. hurd-getty-configuration
  29. hurd-getty-service-type))
  30. ;;; Commentary:
  31. ;;;
  32. ;;; This module implements services for the Hurd.
  33. ;;;
  34. ;;; Code:
  35. ;;;
  36. ;;; The Hurd VGA console service.
  37. ;;;
  38. (define-record-type* <hurd-console-configuration>
  39. hurd-console-configuration make-hurd-console-configuration
  40. hurd-console-configuration?
  41. (hurd hurd-console-configuration-hurd ;package
  42. (default hurd)))
  43. (define (hurd-console-shepherd-service config)
  44. "Return a <shepherd-service> for a Hurd VGA console with CONFIG."
  45. (define console-command
  46. #~(list
  47. (string-append #$(hurd-console-configuration-hurd config) "/bin/console")
  48. "-c" "/dev/vcs"
  49. "-d" "vga"
  50. "-d" "pc_kbd"
  51. "-d" "generic_speaker"))
  52. (list (shepherd-service
  53. (documentation "Run the Hurd’s VGA console client.")
  54. (provision '(console))
  55. (requirement '(user-processes))
  56. (start #~(make-forkexec-constructor #$console-command))
  57. (stop #~(make-kill-destructor)))))
  58. (define hurd-console-service-type
  59. (service-type
  60. (name 'console)
  61. (description "Run the Hurd console client.")
  62. (extensions
  63. (list (service-extension shepherd-root-service-type
  64. hurd-console-shepherd-service)))
  65. (default-value (hurd-console-configuration))))
  66. ;;;
  67. ;;; The Hurd getty service.
  68. ;;;
  69. (define-record-type* <hurd-getty-configuration>
  70. hurd-getty-configuration make-hurd-getty-configuration
  71. hurd-getty-configuration?
  72. (hurd hurd-getty-configuration-hurd ;<package>
  73. (default hurd))
  74. (tty hurd-getty-configuration-tty) ;string
  75. (baud-rate hurd-getty-configuration-baud-rate
  76. (default 38400))) ;integer
  77. (define (hurd-getty-shepherd-service config)
  78. "Return a <shepherd-service> for a Hurd getty with CONFIG."
  79. (let ((hurd (hurd-getty-configuration-hurd config))
  80. (tty (hurd-getty-configuration-tty config))
  81. (baud-rate (hurd-getty-configuration-baud-rate config)))
  82. (define getty-command
  83. #~(list
  84. (string-append #$hurd "/libexec/getty")
  85. #$(number->string baud-rate)
  86. #$tty))
  87. (list
  88. (shepherd-service
  89. (documentation "Run getty on a tty.")
  90. (provision (list (string->symbol (string-append "term-" tty))))
  91. (requirement '(user-processes console))
  92. (start #~(make-forkexec-constructor #$getty-command))
  93. (stop #~(make-kill-destructor))))))
  94. (define hurd-getty-service-type
  95. (service-type
  96. (name 'getty)
  97. (extensions (list (service-extension shepherd-root-service-type
  98. hurd-getty-shepherd-service)))
  99. (description
  100. "Provide console login using the Hurd @command{getty} program.")))
  101. ;;; hurd.scm ends here