guix-service.el 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ;;; guix-service.el --- Guix services -*- lexical-binding: t -*-
  2. ;; Copyright © 2018 Alex Kost <alezost@gmail.com>
  3. ;; This file is part of Emacs-Guix.
  4. ;; Emacs-Guix is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;;
  9. ;; Emacs-Guix is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with Emacs-Guix. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;; This file provides a general code related to Guix services.
  18. ;;; Code:
  19. (require 'guix-read)
  20. (require 'guix-repl)
  21. (require 'guix-guile)
  22. (require 'guix-location)
  23. ;;;###autoload
  24. (defun guix-find-service-location-file (file &optional directory)
  25. "Open service location FILE.
  26. See `guix-find-location' for the meaning of DIRECTORY.
  27. Interactively, prompt for the location FILE. With prefix
  28. argument, prompt for DIRECTORY as well."
  29. (interactive
  30. (list (guix-read-service-location-file)
  31. (guix-read-directory)))
  32. (guix-find-location file directory))
  33. (defun guix-service-location (id-or-name)
  34. "Return location of a service with ID-OR-NAME.
  35. For the meaning of location, see `guix-find-location'."
  36. (guix-eval-read (guix-make-guile-expression
  37. 'service-location-string id-or-name)))
  38. ;;;###autoload
  39. (defun guix-find-service-definition (id-or-name &optional directory)
  40. "Go to the location of service with ID-OR-NAME.
  41. See `guix-find-location' for the meaning of location and
  42. DIRECTORY.
  43. Interactively, with prefix argument, prompt for DIRECTORY."
  44. (interactive
  45. (list (guix-read-service-name)
  46. (guix-read-directory)))
  47. (let ((loc (guix-service-location id-or-name)))
  48. (if loc
  49. (guix-find-location loc directory)
  50. (message "Couldn't find service location."))))
  51. (provide 'guix-service)
  52. ;;; guix-service.el ends here