guix-config.el 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ;;; guix-config.el --- Configuration variables
  2. ;; Copyright © 2016–2017 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 configuration variables for Emacs-Guix package.
  18. ;; Mainly, it is a wrapper for either `guix-build-config' or
  19. ;; `guix-default-config'. Why? Well, when Emacs-Guix is built using
  20. ;; the GNU Build System (./configure and make), "guix-build-config.el"
  21. ;; file is generated, se we can use it. But when Emacs-Guix is used
  22. ;; without building (e.g., from MELPA), we don't have this file, so
  23. ;; instead, there is "guix-default-config.el" with the same variables.
  24. ;;; Code:
  25. (or (require 'guix-build-config nil t)
  26. (require 'guix-default-config))
  27. (require 'cl-lib)
  28. (defun guix-first-existing-file (&rest file-names)
  29. "Return the first existing file from FILE-NAMES."
  30. (cl-find-if #'file-exists-p file-names))
  31. ;; Avoid compilation warnings.
  32. (defvar guix-config-scheme-directory)
  33. (defvar guix-config-image-directory)
  34. (defvar guix-elisp-directory
  35. (file-name-directory load-file-name)
  36. "Directory with Elisp files for Emacs-Guix package.")
  37. (defvar guix-scheme-directory
  38. ;; If `guix-config-scheme-directory' is nil, then Emacs-Guix is used
  39. ;; from source without building (i.e., from MELPA), so find Scheme
  40. ;; files in a relative directory.
  41. (or guix-config-scheme-directory
  42. (guix-first-existing-file
  43. (expand-file-name "scheme" guix-elisp-directory)
  44. (expand-file-name "../scheme" guix-elisp-directory))
  45. (progn
  46. (message "WARNING: Can't define `guix-scheme-directory'!")
  47. nil))
  48. "Directory with Scheme files for Emacs-Guix package.
  49. It should be a directory where Guile modules are placed, i.e. a
  50. directory with 'emacs-guix' sub-directory.")
  51. (defvar guix-image-directory
  52. (or guix-config-image-directory
  53. (guix-first-existing-file
  54. (expand-file-name "images" guix-elisp-directory)
  55. (expand-file-name "../images" guix-elisp-directory))
  56. (progn
  57. (message "WARNING: Can't define `guix-image-directory'!")
  58. nil))
  59. "Directory with image files for Emacs-Guix package.")
  60. (defvar guix-state-directory
  61. ;; guix-daemon honors `NIX_STATE_DIR'.
  62. (or (getenv "NIX_STATE_DIR")
  63. (guix-first-existing-file "/var/guix"
  64. "/usr/local/var/guix")
  65. (progn
  66. ;; If "/var" does not exist, we are probably being compiled by
  67. ;; guix. Do not emit a warning in this case.
  68. (when (file-exists-p "/var")
  69. (message "WARNING: Can't define `guix-state-directory'!"))
  70. "/var/guix"))
  71. "Guix local state directory.
  72. This directory is used to define default Guix profiles. Set it
  73. to a proper value, if you configure your Guix with a non-standard
  74. --localstatedir option. See Info node `(guix) Invoking guix
  75. package' and other nodes for the meaning of --localstatedir
  76. configure option.")
  77. (provide 'guix-config)
  78. ;;; guix-config.el ends here