diff options
Diffstat (limited to 'doc/guix.texi')
-rw-r--r-- | doc/guix.texi | 333 |
1 files changed, 278 insertions, 55 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 2298d512a1..2f52a23c18 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -289,6 +289,7 @@ Utilities * Invoking guix hash:: Computing the cryptographic hash of a file. * Invoking guix import:: Importing package definitions. * Invoking guix refresh:: Updating package definitions. +* Invoking guix style:: Styling package definitions. * Invoking guix lint:: Finding errors in package definitions. * Invoking guix size:: Profiling disk usage. * Invoking guix graph:: Visualizing the graph of packages. @@ -1892,12 +1893,12 @@ themselves. @subsection X11 Fonts @cindex fonts -The majority of graphical applications use Fontconfig to locate and -load fonts and perform X11-client-side rendering. The @code{fontconfig} -package in Guix looks for fonts in @file{$HOME/.guix-profile} -by default. Thus, to allow graphical applications installed with Guix -to display fonts, you have to install fonts with Guix as well. -Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and +The majority of graphical applications use Fontconfig to locate and load +fonts and perform X11-client-side rendering. The @code{fontconfig} +package in Guix looks for fonts in @file{$HOME/.guix-profile} by +default. Thus, to allow graphical applications installed with Guix to +display fonts, you have to install fonts with Guix as well. Essential +font packages include @code{font-ghostscript}, @code{font-dejavu}, and @code{font-gnu-freefont}. @cindex @code{fc-cache} @@ -2785,8 +2786,8 @@ you should add them to @file{~/.bash_profile} (or equivalent file if you do not use Bash) so that environment variables are set next time you spawn a shell. You only need to do this once and other search paths environment variables will be taken care of similarly---e.g., if you -eventually install @code{python} and Python libraries, @code{PYTHONPATH} -will be defined. +eventually install @code{python} and Python libraries, +@env{GUIX_PYTHONPATH} will be defined. You can go on installing packages at your will. To list installed packages, run: @@ -3530,24 +3531,26 @@ Show details about @var{package}, taken from the list of available packages, in recutils manual}). @example -$ guix package --show=python | recsel -p name,version -name: python -version: 2.7.6 +$ guix package --show=guile | recsel -p name,version +name: guile +version: 3.0.5 -name: python -version: 3.3.5 +name: guile +version: 3.0.2 + +name: guile +version: 2.2.7 +@dots{} @end example You may also specify the full name of a package to only get details about a specific version of it (this time using the @command{guix show} alias): @example -$ guix show python@@3.4 | recsel -p name,version -name: python -version: 3.4.3 +$ guix show guile@@3.0.5 | recsel -p name,version +name: guile +version: 3.0.5 @end example - - @item --list-installed[=@var{regexp}] @itemx -I [@var{regexp}] List the currently installed packages in the specified profile, with the @@ -5627,11 +5630,11 @@ guix environment guile -- make -j4 In other situations, it is more convenient to specify the list of packages needed in the environment. For example, the following command -runs @command{python} from an environment containing Python@tie{}2.7 and +runs @command{python} from an environment containing Python@tie{}3 and NumPy: @example -guix environment --ad-hoc python2-numpy python-2.7 -- python +guix environment --ad-hoc python-numpy python -- python3 @end example Furthermore, one might want the dependencies of a package and also some @@ -6506,7 +6509,7 @@ package looks like this: "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))) (build-system gnu-build-system) (arguments '(#:configure-flags '("--enable-silent-rules"))) - (inputs `(("gawk" ,gawk))) + (inputs (list gawk)) (synopsis "Hello, GNU world: An example GNU package") (description "Guess what GNU Hello prints!") (home-page "https://www.gnu.org/software/hello/") @@ -6594,8 +6597,8 @@ Reference Manual}). @item The @code{inputs} field specifies inputs to the build process---i.e., -build-time or run-time dependencies of the package. Here, we define an -input called @code{"gawk"} whose value is that of the @code{gawk} +build-time or run-time dependencies of the package. Here, we add +an input, a reference to the @code{gawk} variable; @code{gawk} is itself bound to a @code{<package>} object. @cindex backquote (quasiquote) @@ -6720,20 +6723,42 @@ list, typically containing sequential keyword-value pairs. @itemx @code{native-inputs} (default: @code{'()}) @itemx @code{propagated-inputs} (default: @code{'()}) @cindex inputs, of packages -These fields list dependencies of the package. Each one is a list of -tuples, where each tuple has a label for the input (a string) as its +These fields list dependencies of the package. Each element of these +lists is either a package, origin, or other ``file-like object'' +(@pxref{G-Expressions}); to specify the output of that file-like object +that should be used, pass a two-element list where the second element is +the output (@pxref{Packages with Multiple Outputs}, for more on package +outputs). For example, the list below specifies three inputs: + +@lisp +(list libffi libunistring + `(,glib "bin")) ;the "bin" output of GLib +@end lisp + +In the example above, the @code{"out"} output of @code{libffi} and +@code{libunistring} is used. + +@quotation Compatibility Note +Until version 1.3.0, input lists were a list of tuples, +where each tuple has a label for the input (a string) as its first element, a package, origin, or derivation as its second element, and optionally the name of the output thereof that should be used, which -defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for -more on package outputs). For example, the list below specifies three -inputs: +defaults to @code{"out"}. For example, the list below is equivalent to +the one above, but using the @dfn{old input style}: @lisp +;; Old input style (deprecated). `(("libffi" ,libffi) ("libunistring" ,libunistring) - ("glib:bin" ,glib "bin")) ;the "bin" output of Glib + ("glib:bin" ,glib "bin")) ;the "bin" output of GLib @end lisp +This style is now deprecated; it is still supported but support will be +removed in a future version. It should not be used for new package +definitions. @xref{Invoking guix style}, on how to migrate to the new +style. +@end quotation + @cindex cross compilation, package dependencies The distinction between @code{native-inputs} and @code{inputs} is necessary when considering cross-compilation. When cross-compiling, @@ -6819,13 +6844,37 @@ cross-compiling: ;; When cross-compiled, Guile, for example, depends on ;; a native version of itself. Add it here. (native-inputs (if (%current-target-system) - `(("self" ,this-package)) + (list this-package) '()))) @end lisp It is an error to refer to @code{this-package} outside a package definition. @end deffn +The following helper procedures are provided to help deal with package +inputs. + +@deffn {Scheme Procedure} lookup-package-input @var{package} @var{name} +@deffnx {Scheme Procedure} lookup-package-native-input @var{package} @var{name} +@deffnx {Scheme Procedure} lookup-package-propagated-input @var{package} @var{name} +@deffnx {Scheme Procedure} lookup-package-direct-input @var{package} @var{name} +Look up @var{name} among @var{package}'s inputs (or native, propagated, +or direct inputs). Return it if found, @code{#f} otherwise. + +@var{name} is the name of a package depended on. Here's how you might +use it: + +@lisp +(use-modules (guix packages) (gnu packages base)) + +(lookup-package-direct-input coreutils "gmp") +@result{} #<package gmp@@6.2.1 @dots{}> +@end lisp + +In this example we obtain the @code{gmp} package that is among the +direct inputs of @code{coreutils}. +@end deffn + Because packages are regular Scheme objects that capture a complete dependency graph and associated build procedures, it is often useful to write procedures that take a package and return a modified version @@ -7105,20 +7154,42 @@ optional dependency, you can define a variant that removes that dependency like so: @lisp -(use-modules (gnu packages gdb) ;for 'gdb' - (srfi srfi-1)) ;for 'alist-delete' +(use-modules (gnu packages gdb)) ;for 'gdb' (define gdb-sans-guile (package (inherit gdb) - (inputs (alist-delete "guile" - (package-inputs gdb))))) + (inputs (modify-inputs (package-inputs gdb) + (delete "guile"))))) @end lisp -The @code{alist-delete} call above removes the tuple from the -@code{inputs} field that has @code{"guile"} as its first element -(@pxref{SRFI-1 Association Lists,,, guile, GNU Guile Reference -Manual}). +The @code{modify-inputs} form above removes the @code{"guile"} package +from the @code{inputs} field of @code{gdb}. The @code{modify-inputs} +macro is a helper that can prove useful anytime you want to remove, add, +or replace package inputs. + +@deffn {Scheme Syntax} modify-inputs @var{inputs} @var{clauses} +Modify the given package inputs, as returned by @code{package-inputs} & co., +according to the given clauses. The example below removes the GMP and ACL +inputs of Coreutils and adds libcap to the back of the input list: + +@lisp +(modify-inputs (package-inputs coreutils) + (delete "gmp" "acl") + (append libcap)) +@end lisp + +The example below replaces the @code{guile} package from the inputs of +@code{guile-redis} with @code{guile-2.2}: + +@lisp +(modify-inputs (package-inputs guile-redis) + (replace "guile" guile-2.2)) +@end lisp + +The last type of clause is @code{prepend}, to add inputs to the front of +the list. +@end deffn In some cases, you may find it useful to write functions (``procedures'', in Scheme parlance) that return a package based on some @@ -7135,8 +7206,7 @@ depends on it: (name name) (version "3.0") ;; several fields omitted - (inputs - `(("lua" ,lua))) + (inputs (list lua)) (synopsis "Socket library for Lua"))) (define-public lua5.1-socket @@ -7960,8 +8030,9 @@ packages, which consists in running @code{python setup.py build} and then @code{python setup.py install --prefix=/gnu/store/@dots{}}. For packages that install stand-alone Python programs under @code{bin/}, -it takes care of wrapping these programs so that their @env{PYTHONPATH} -environment variable points to all the Python libraries they depend on. +it takes care of wrapping these programs so that their +@env{GUIX_PYTHONPATH} environment variable points to all the Python +libraries they depend on. Which Python package is used to perform the build can be specified with the @code{#:python} parameter. This is a useful way to force a package @@ -7973,6 +8044,13 @@ By default guix calls @code{setup.py} under control of @code{setuptools}, much like @command{pip} does. Some packages are not compatible with setuptools (and pip), thus you can disable this by setting the @code{#:use-setuptools?} parameter to @code{#f}. + +If a @code{"python"} output is available, the package is installed into it +instead of the default @code{"out"} output. This is useful for packages that +include a Python package as only a part of the software, and thus want to +combine the phases of @code{python-build-system} with another build system. +Python bindings are a common usecase. + @end defvr @defvr {Scheme Variable} perl-build-system @@ -8193,9 +8271,7 @@ implements the build procedure for packages that use It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set of inputs, and they can be changed with the parameters @code{#:meson} -and @code{#:ninja} if needed. The default Meson is -@code{meson-for-build}, which is special because it doesn't clear the -@code{RUNPATH} of binaries and libraries when they are installed. +and @code{#:ninja} if needed. This build system is an extension of @code{gnu-build-system}, but with the following phases changed to some specific for Meson: @@ -8226,11 +8302,11 @@ Apart from that, the build system also adds the following phases: @item fix-runpath This phase ensures that all binaries can find the libraries they need. -It searches for required libraries in subdirectories of the package being -built, and adds those to @code{RUNPATH} where needed. It also removes -references to libraries left over from the build phase by -@code{meson-for-build}, such as test dependencies, that aren't actually -required for the program to run. +It searches for required libraries in subdirectories of the package +being built, and adds those to @code{RUNPATH} where needed. It also +removes references to libraries left over from the build phase by +@code{meson}, such as test dependencies, that aren't actually required +for the program to run. @item glib-or-gtk-wrap This phase is the phase provided by @code{glib-or-gtk-build-system}, and it @@ -8609,12 +8685,14 @@ Make @var{file} writable for its owner. @end deffn @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @ - [#:log (current-output-port)] [#:follow-symlinks? #f] [#:keep-mtime? #f] + [#:log (current-output-port)] [#:follow-symlinks? #f] @ + [#:copy-file copy-file] [#:keep-mtime? #f] [#:keep-permissions? #t] Copy @var{source} directory to @var{destination}. Follow symlinks if -@var{follow-symlinks?} is true; otherwise, just preserve them. When -@var{keep-mtime?} is true, keep the modification time of the files in -@var{source} on those of @var{destination}. Write verbose output to the -@var{log} port. +@var{follow-symlinks?} is true; otherwise, just preserve them. Call +@var{copy-file} to copy regular files. When @var{keep-mtime?} is true, +keep the modification time of the files in @var{source} on those of +@var{destination}. When @var{keep-permissions?} is true, preserve file +permissions. Write verbose output to the @var{log} port. @end deffn @deffn {Scheme Procedure} delete-file-recursively @var{dir} @ @@ -8698,6 +8776,31 @@ Return the complete file name for @var{program} as found in @code{$PATH}, or @code{#f} if @var{program} could not be found. @end deffn +@deffn {Scheme Procedure} search-input-file @var{inputs} @var{name} +@deffnx {Scheme Procedure} search-input-directory @var{inputs} @var{name} +Return the complete file name for @var{name} as found in @var{inputs}; +@code{search-input-file} searches for a regular file and +@code{search-input-directory} searches for a directory. If @var{name} +could not be found, an exception is raised. + +Here, @var{inputs} must be an association list like @code{inputs} and +@code{native-inputs} as available to build phases (@pxref{Build +Phases}). +@end deffn + +Here is a (simplified) example of how @code{search-input-file} is used +in a build phase of the @code{wireguard-tools} package: + +@lisp +(add-after 'install 'wrap-wg-quick + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((coreutils (string-append (assoc-ref inputs "coreutils") + "/bin"))) + (wrap-program (search-input-file outputs "bin/wg-quick") + #:sh (search-input-file inputs "bin/bash") + `("PATH" ":" prefix ,(list coreutils)))))) +@end lisp + @subsection Build Phases @cindex build phases @@ -10195,6 +10298,7 @@ the Scheme programming interface of Guix in a convenient way. * Invoking guix hash:: Computing the cryptographic hash of a file. * Invoking guix import:: Importing package definitions. * Invoking guix refresh:: Updating package definitions. +* Invoking guix style:: Styling package definitions. * Invoking guix lint:: Finding errors in package definitions. * Invoking guix size:: Profiling disk usage. * Invoking guix graph:: Visualizing the graph of packages. @@ -12017,6 +12121,98 @@ token procured from @uref{https://github.com/settings/tokens} or otherwise. +@node Invoking guix style +@section Invoking @command{guix style} + +The @command{guix style} command helps packagers style their package +definitions according to the latest fashionable trends. The command +currently focuses on one aspect: the style of package inputs. It may +eventually be extended to handle other stylistic matters. + +The way package inputs are written is going through a transition +(@pxref{package Reference}, for more on package inputs). Until version +1.3.0, package inputs were written using the ``old style'', where each +input was given an explicit label, most of the time the package name: + +@lisp +(package + ;; @dots{} + ;; The "old style" (deprecated). + (inputs `(("libunistring" ,libunistring) + ("libffi" ,libffi)))) +@end lisp + +Today, the old style is deprecated and the preferred style looks like +this: + +@lisp +(package + ;; @dots{} + ;; The "new style". + (inputs (list libunistring libffi))) +@end lisp + +Likewise, uses of @code{alist-delete} and friends to manipulate inputs +is now deprecated in favor of @code{modify-inputs} (@pxref{Defining +Package Variants}, for more info on @code{modify-inputs}). + +In the vast majority of cases, this is a purely mechanical change on the +surface syntax that does not even incur a package rebuild. Running +@command{guix style} can do that for you, whether you're working on +packages in Guix proper or in an external channel. + +The general syntax is: + +@example +guix style [@var{options}] @var{package}@dots{} +@end example + +This causes @command{guix style} to analyze and rewrite the definition +of @var{package}@dots{}. It does so in a conservative way: preserving +comments and bailing out if it cannot make sense of the code that +appears in an inputs field. The available options are listed below. + +@table @code +@item --load-path=@var{directory} +@itemx -L @var{directory} +Add @var{directory} to the front of the package module search path +(@pxref{Package Modules}). + +@item --expression=@var{expr} +@itemx -e @var{expr} +Style the package @var{expr} evaluates to. + +For example, running: + +@example +guix style -e '(@@ (gnu packages gcc) gcc-5)' +@end example + +styles the @code{gcc-5} package definition. + +@item --input-simplification=@var{policy} +Specify the package input simplification policy for cases where an input +label does not match the corresponding package name. @var{policy} may +be one of the following: + +@table @code +@item silent +Simplify inputs only when the change is ``silent'', meaning that the +package does not need to be rebuilt (its derivation is unchanged). + +@item safe +Simplify inputs only when that is ``safe'' to do: the package might need +to be rebuilt, but the change is known to have no observable effect. + +@item always +Simplify inputs even when input labels do not match package names, and +even if that might have an observable effect. +@end table + +The default is @code{silent}, meaning that input simplifications do not +trigger any package rebuild. +@end table + @node Invoking guix lint @section Invoking @command{guix lint} @@ -12145,6 +12341,13 @@ declare them as in this example: @item formatting Warn about obvious source code formatting issues: trailing white space, use of tabulations, etc. + +@item input-labels +Report old-style input labels that do not match the name of the +corresponding package. This aims to help migrate from the ``old input +style''. @xref{package Reference}, for more information on package +inputs and input styles. @xref{Invoking guix style}, on how to migrate +to the new style. @end table The general syntax is: @@ -18486,6 +18689,12 @@ programs. Defaults to @samp{"lp"}. @end deftypevr +@deftypevr {@code{files-configuration} parameter} string log-file-group +Specifies the group name or ID that will be used for log files. + +Defaults to @samp{"lpadmin"}. +@end deftypevr + @deftypevr {@code{files-configuration} parameter} string log-file-perm Specifies the permissions for all log files that the scheduler writes. @@ -34898,6 +35107,20 @@ GDB}): From there on, GDB will pick up debugging information from the @file{.debug} files under @file{~/.guix-profile/lib/debug}. +Below is an alternative GDB script which is useful when working with +other profiles. It takes advantage of the optional Guile integration in +GDB. This snippet is included by default on Guix System in the +@file{~/.gdbinit} file. + +@example +guile +(use-modules (gdb)) +(execute (string-append "set debug-file-directory " + (or (getenv "GDB_DEBUG_FILE_DIRECTORY") + "~/.guix-profile/lib/debug"))) +end +@end example + In addition, you will most likely want GDB to be able to show the source code being debugged. To do that, you will have to unpack the source code of the package of interest (obtained with @code{guix build |