guile-daemon.texi 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. \input texinfo
  2. @setfilename guile-daemon.info
  3. @documentencoding UTF-8
  4. @settitle Guile-Daemon Reference Manual
  5. @include version.texi
  6. @copying
  7. This document describes Guile-Daemon version @value{VERSION}, a
  8. program used to execute an arbitrary Guile code that it receives from
  9. a FIFO file.
  10. @quotation
  11. Copyright @copyright{} 2017, 2020 Alex Kost
  12. Permission is granted to copy, distribute and/or modify this document
  13. under the terms of the GNU Free Documentation License, Version 1.3
  14. or any later version published by the Free Software Foundation;
  15. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  16. A copy of the license is available at
  17. @url{http://www.gnu.org/licenses/fdl.html}.
  18. @end quotation
  19. @end copying
  20. @dircategory The Algorithmic Language Scheme
  21. @direntry
  22. * Guile-Daemon: (guile-daemon). Daemon for executing user Guile code.
  23. @end direntry
  24. @titlepage
  25. @title Guile-Daemon Reference Manual
  26. @subtitle for Guile-Daemon @value{VERSION}
  27. @author Alex Kost
  28. @page
  29. @vskip 0pt plus 1filll
  30. @insertcopying
  31. @end titlepage
  32. @contents
  33. @c ----------------------------------------------------------------
  34. @node Top
  35. @top Guile-Daemon
  36. @insertcopying
  37. @menu
  38. * Introduction:: Quick overview.
  39. * Installation:: Installing Guile-Daemon.
  40. * Command-line Options:: Command-line options for @code{guile-daemon}.
  41. * The REPL:: Interacting with the Guile-Daemon REPL.
  42. * Hacking:: How to modify Guile-Daemon code.
  43. @end menu
  44. @node Introduction
  45. @chapter Introduction
  46. Guile-Daemon is a small Guile program (called @code{guile-daemon})
  47. that loads your initial configuration file, and then reads and
  48. evaluates Guile expressions that you send to a FIFO file. That's
  49. basically it.
  50. You can send Guile expressions to the daemon either manually directing
  51. them to the FIFO file, or using a simple shell script (called
  52. @code{gdpipe}).
  53. Finally, you can also connect to the daemon using a socket file
  54. (@pxref{The REPL}).
  55. @node Installation
  56. @chapter Installation
  57. @cindex installation
  58. There are several ways to install Guile-Daemon:
  59. @itemize
  60. @item
  61. Installing using @uref{http://gnu.org/software/guix/, GNU Guix}
  62. @example
  63. $ guix package -i guile-daemon
  64. @end example
  65. @item
  66. Installing manually (@code{make install}).
  67. @item
  68. Using from a git checkout.
  69. @end itemize
  70. If you installed Guile-Daemon with Guix or another package manager,
  71. you can skip this chapter. For the rest options, read further.
  72. @menu
  73. * Requirements:: Required dependencies.
  74. * Manual Installation:: @code{./configure && make && make install}.
  75. * Using from Git:: Using without installation.
  76. @end menu
  77. @node Requirements
  78. @section Requirements
  79. Guile-Daemon depends only on @uref{http://gnu.org/software/guile/, GNU
  80. Guile}, version 2.0.2 or later.
  81. However, if you want to build it manually from a release tarball, make
  82. sure you have a usual toolset for the GNU Build System (in particular,
  83. @code{make} and @code{pkg-config}).
  84. And if you want to build it from a git checkout, you also need
  85. autotools (@code{autoconf} and @code{automake}) and @code{texinfo} to
  86. build the manual.
  87. @node Manual Installation
  88. @section Manual Installation
  89. If you want to install Guile-Daemon manually, at first, you need to
  90. get a release tarball. It can be found at
  91. @uref{https://github.com/alezost/guile-daemon/releases}.
  92. Now you can build it with the usual sequence of commands of the GNU
  93. Build System:
  94. @example
  95. $ ./configure
  96. $ make
  97. # make install
  98. @end example
  99. For more details on the installation process, see @file{INSTALL} file.
  100. @strong{Important:} Guile modules are installed under the configured
  101. @code{prefix}. A typical module directory will be
  102. @file{/usr/local/share/guile/site/2.2/}). However, Guile does not
  103. search for modules in @file{/usr/local/...}, so most likely you would
  104. want to configure the package using @code{--with-guile-site-dir} and
  105. @code{--with-guile-site-ccache-dir} options, like this:
  106. @example
  107. $ ./configure --with-guile-site-dir=/usr/share/guile/site/2.2 \
  108. --with-guile-site-ccache-dir=/usr/lib/guile/2.2/site-ccache
  109. @end example
  110. These are the default directories where @file{*.scm} and @file{*.go}
  111. files should go if Guile was installed into @code{/usr}. Of course,
  112. you can specify any other directories, but make sure to add them to
  113. @code{GUILE_LOAD_PATH} and @code{GUILE_LOAD_COMPILED_PATH} accordingly
  114. (@pxref{Environment Variables,,, guile, The GNU Guile Reference
  115. Manual}).
  116. Alternatively, you can just install Guile-Daemon using the same prefix
  117. as was specified for Guile:
  118. @example
  119. $ ./configure --prefix=/usr
  120. @end example
  121. @node Using from Git
  122. @section Using from Git
  123. It is possible to use Guile-Daemon directly from a git checkout,
  124. without installation. At first, clone the repository and build it:
  125. @example
  126. $ git clone https://github.com/alezost/guile-daemon.git
  127. $ cd guile-daemon
  128. @end example
  129. Now make sure you have all the required dependencies
  130. (@pxref{Requirements}). If you use Guix, you may use @file{guix.scm}
  131. file to make the needed environment (@pxref{Invoking guix
  132. environment,,, guix, The GNU Guix Reference Manual}):
  133. @example
  134. $ guix environment --pure --load=guix.scm
  135. @end example
  136. Finally, run @code{autogen.sh} script (it's just a wrapper for
  137. @code{autoreconf} command) and build Guile-Daemon:
  138. @example
  139. $ ./autogen.sh
  140. $ ./configure
  141. $ make
  142. @end example
  143. Now you can run @code{guile-daemon} using a generated
  144. @file{pre-inst-env} shell script@footnote{@xref{Hacking}, for details
  145. about @file{pre-inst-env} script.}:
  146. @example
  147. $ ./pre-inst-env guile-daemon
  148. @end example
  149. And send Guile expressions to it with @file{gdpipe}:
  150. @example
  151. $ scripts/gdpipe '(with-output-to-file "/tmp/hello" (lambda () (display "Hello!")))'
  152. @end example
  153. @node Command-line Options
  154. @chapter Command-line Options
  155. You can run Guile-Daemon with the following command-line arguments:
  156. @table @code
  157. @item -h
  158. @itemx --help
  159. Display a short help message and exit.
  160. @item -V
  161. @itemx --version
  162. Display version and exit.
  163. @item -c @var{file}
  164. @itemx --config=@var{file}
  165. Load startup configuration from @var{file} instead of the default
  166. @file{$XDG_CONFIG_HOME/guile-daemon/init.scm}.@footnote{If
  167. @code{XDG_CONFIG_HOME} environment variable is not set,
  168. @file{$HOME/.config} directory is used.}
  169. @item -f @var{file}
  170. @itemx --fifo=@var{file}
  171. Use FIFO @var{file} instead of the default
  172. @file{$XDG_RUNTIME_DIR/guile-daemon/fifo}.
  173. @item -s @var{file}
  174. @itemx --socket=@var{file}
  175. Use socket @var{file} instead of the default
  176. @file{$XDG_RUNTIME_DIR/guile-daemon/socket}.
  177. @end table
  178. @node The REPL
  179. @chapter The REPL
  180. As mentioned in the Introduction (@pxref{Introduction}), you can
  181. connect to the running guile-daemon process using a socket file, thus
  182. you can have a direct access to it via the Guile REPL (@pxref{The
  183. REPL,,, guile, The GNU Guile Reference Manual}).
  184. By default, the socket file name is
  185. @file{$XDG_RUNTIME_DIR/guile-daemon/socket}. You can change it
  186. with @code{--socket} option (@pxref{Command-line Options}).
  187. If you use @uref{http://gnu.org/software/emacs/, GNU Emacs} and
  188. @uref{https://github.com/jaor/geiser, Geiser}, the best way to connect
  189. to the socket file is @kbd{M-x geiser-connect-local} command.
  190. @node Hacking
  191. @chapter Hacking
  192. If you use Guile-Daemon from a git checkout (@pxref{Using from Git}),
  193. you may be interested in modifying it, or you may just wonder what
  194. @file{pre-inst-env} script does. This chapter describes some details
  195. on this subject.
  196. After building a git checkout, you can't simply execute
  197. @file{scripts/guile-daemon} because it needs some Guile modules from
  198. the checkout. This is why @file{pre-inst-env} is needed. Basically
  199. it just sets @code{GUILE_LOAD_PATH} and
  200. @code{GUILE_LOAD_COMPILED_PATH} variables (@pxref{Environment
  201. Variables,,, guile, The GNU Guile Reference Manual}) and runs the
  202. specified command, so it may be used like this:
  203. @example
  204. $ ./pre-inst-env guile
  205. scheme@@(guile-user)> ,use(daemon defaults)
  206. scheme@@(guile-user)> %default-fifo-file
  207. $1 = "/run/user/1000/guile-daemon/fifo"
  208. @end example
  209. If you live in Emacs, you may find @file{pre-inst-env.el} more useful.
  210. If you load this file (for example, with @kbd{M-x load-file}), it will
  211. set the environment inside Emacs, so you can run Guile in @kbd{M-x
  212. shell}, or more importantly start Geiser and use Guile-Daemon modules
  213. there.
  214. @bye