mcron.scm 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2021, 2023 Andrew Tropin <andrew@trop.in>
  3. ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
  4. ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  5. ;;; Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (gnu home services mcron)
  22. #:use-module (gnu home services)
  23. #:use-module (gnu home services shepherd)
  24. #:use-module (gnu services mcron) ;for the service mapping
  25. #:export (home-mcron-configuration
  26. home-mcron-service-type))
  27. ;;; Commentary:
  28. ;;
  29. ;; Service for the GNU mcron cron job manager.
  30. ;;
  31. ;; Example configuration, the first job runs mbsync once every ten
  32. ;; minutes, the second one writes "Mcron service" to ~/mcron-file once
  33. ;; every minute.
  34. ;;
  35. ;; (service home-mcron-service-type
  36. ;; (home-mcron-configuration
  37. ;; (jobs (list #~(job '(next-minute
  38. ;; (range 0 60 10))
  39. ;; (lambda ()
  40. ;; (system* "mbsync" "--all")))
  41. ;; #~(job next-minute-from
  42. ;; (lambda ()
  43. ;; (call-with-output-file (string-append (getenv "HOME")
  44. ;; "/mcron-file")
  45. ;; (lambda (port)
  46. ;; (display "Mcron service" port)))))))))
  47. ;;
  48. ;;; Code:
  49. (define-syntax-rule (home-mcron-configuration fields ...)
  50. ;; Macro provided for backward compatibility.
  51. (for-home (mcron-configuration fields ...)))
  52. (define home-mcron-service-type
  53. (service-type
  54. (inherit (system->home-service-type mcron-service-type))
  55. (default-value (for-home (mcron-configuration)))))
  56. (define-service-type-mapping
  57. mcron-service-type => home-mcron-service-type)
  58. ;;; mcron.scm ends here