messaging.scm 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2023 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 home services messaging)
  19. #:use-module (srfi srfi-26)
  20. #:use-module (gnu home services)
  21. #:use-module (gnu home services shepherd)
  22. #:use-module (gnu packages messaging)
  23. #:use-module (gnu services configuration)
  24. #:use-module (gnu services shepherd)
  25. #:use-module (guix records)
  26. #:use-module (guix gexp)
  27. #:export (home-znc-configuration
  28. home-znc-service-type))
  29. ;;;
  30. ;;; Znc.
  31. ;;;
  32. (define-record-type* <home-znc-configuration>
  33. home-znc-configuration make-home-znc-configuration
  34. home-znc-configuration?
  35. (znc home-znc-znc ;string
  36. (default znc))
  37. (extra-options home-znc-extra-options ;list of string
  38. (default '())))
  39. (define (home-znc-services config)
  40. "Return a <shepherd-service> for znc with CONFIG."
  41. (match-record config <home-znc-configuration>
  42. (znc extra-options)
  43. (let* ((znc (file-append znc "/bin/znc"))
  44. (command #~'(#$znc "--foreground" #$@extra-options))
  45. (log-file #~(string-append %user-log-dir "/znc.log")))
  46. (list (shepherd-service
  47. (documentation "Run the znc IRC bouncer.")
  48. (provision '(znc))
  49. (modules '((shepherd support))) ;for '%user-log-dir'
  50. (start #~(make-forkexec-constructor #$command
  51. #:log-file #$log-file))
  52. (stop #~(make-kill-destructor)))))))
  53. (define home-znc-service-type
  54. (service-type
  55. (name 'home-znc)
  56. (default-value (home-znc-configuration))
  57. (extensions
  58. (list (service-extension home-shepherd-service-type
  59. home-znc-services)))
  60. (description
  61. "Install and configure @command{znc}, an @acronym{IRC, Internet Relay
  62. Chat} bouncer, as a Shepherd service.")))