From f6c9fb1b38732fab867db086b0527b01adb03dce Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 28 Nov 2015 15:25:42 +0100 Subject: doc: Mention 'specification->package'. Suggested by Florian Paul Schmidt . * doc/guix.texi (Using the Configuration System): Mention 'specification->package'. --- doc/guix.texi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index ab1e4be20f..f7adfafe54 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5543,6 +5543,26 @@ editor, @command{find}, @command{grep}, etc. The example above adds tcpdump to those, taken from the @code{(gnu packages admin)} module (@pxref{Package Modules}). +@findex specification->package +Referring to packages by variable name, like @var{tcpdump} above, has +the advantage of being unambiguous; it also allows typos and such to be +diagnosed right away as ``unbound variables''. The downside is that one +needs to know which module defines which package, and to augment the +@code{use-package-modules} line accordingly. To avoid that, one can use +the @code{specification->package} procedure of the @code{(gnu packages)} +module, which returns the best package for a given name or name and +version: + +@lisp +(use-modules (gnu packages)) + +(operating-system + ;; ... + (packages (append (map specification->package + '("tcpdump" "htop" "gnupg-2.0")) + %base-packages))) +@end lisp + @vindex %base-services The @code{services} field lists @dfn{system services} to be made available when the system starts (@pxref{Services}). -- cgit v1.2.3