diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2015-06-05 14:53:32 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2015-06-05 15:25:08 +0200 |
| commit | 343eacbec9d9aa2aed5f9c44b9473cc9dc5e9753 (patch) | |
| tree | ffd390a6e8cea7830965f312453a7a3c066ded1f /doc | |
| parent | 97cc51f87605ca78af3b8c2e8094b6f244fbb11a (diff) | |
doc: Explain "file-like objects".
* doc/guix.texi (G-Expressions): Mention "file-like objects" and explain
more.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/guix.texi | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 665bdb028d7..2082fd765cc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -2942,12 +2942,12 @@ and these dependencies are automatically added as inputs to the build | |||
| 2942 | processes that use them. | 2942 | processes that use them. |
| 2943 | @end itemize | 2943 | @end itemize |
| 2944 | 2944 | ||
| 2945 | Actually this mechanism is not limited to package and derivation | 2945 | This mechanism is not limited to package and derivation |
| 2946 | objects; @dfn{compilers} able to ``lower'' other high-level objects to | 2946 | objects: @dfn{compilers} able to ``lower'' other high-level objects to |
| 2947 | derivations can be defined, such that these objects can also be inserted | 2947 | derivations can be defined, such that these objects can also be inserted |
| 2948 | into gexps. Another useful type of high-level object that can be | 2948 | into gexps. For example, a useful type of high-level object that can be |
| 2949 | inserted in a gexp is @dfn{local files}, which allows files from the | 2949 | inserted in a gexp is ``file-like objects'', which make it easy to |
| 2950 | local file system to be added to the store and referred to by | 2950 | add files to the store and refer to them in |
| 2951 | derivations and such (see @code{local-file} and @code{plain-file} | 2951 | derivations and such (see @code{local-file} and @code{plain-file} |
| 2952 | below.) | 2952 | below.) |
| 2953 | 2953 | ||
| @@ -3113,6 +3113,24 @@ refer to. Any reference to another store item will lead to a build error. | |||
| 3113 | The other arguments are as for @code{derivation} (@pxref{Derivations}). | 3113 | The other arguments are as for @code{derivation} (@pxref{Derivations}). |
| 3114 | @end deffn | 3114 | @end deffn |
| 3115 | 3115 | ||
| 3116 | @cindex file-like objects | ||
| 3117 | The @code{local-file} and @code{plain-file} procedures below return | ||
| 3118 | @dfn{file-like objects}. That is, when unquoted in a G-expression, | ||
| 3119 | these objects lead to a file in the store. Consider this G-expression: | ||
| 3120 | |||
| 3121 | @example | ||
| 3122 | #~(system* (string-append #$glibc "/sbin/nscd") "-f" | ||
| 3123 | #$(local-file "/tmp/my-nscd.conf")) | ||
| 3124 | @end example | ||
| 3125 | |||
| 3126 | The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it | ||
| 3127 | to the store. Once expanded, for instance @i{via} | ||
| 3128 | @code{gexp->derivation}, the G-expression refers to that copy under | ||
| 3129 | @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp} | ||
| 3130 | does not have any effect on what the G-expression does. | ||
| 3131 | @code{plain-file} can be used similarly; it differs in that the file | ||
| 3132 | content is directly passed as a string. | ||
| 3133 | |||
| 3116 | @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @ | 3134 | @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @ |
| 3117 | [#:recursive? #t] | 3135 | [#:recursive? #t] |
| 3118 | Return an object representing local file @var{file} to add to the store; this | 3136 | Return an object representing local file @var{file} to add to the store; this |
