Próximo: Using Guix Interactively, Anterior: Expressões-G, Acima: Interface de programação [Conteúdo][Índice]
guix repl
The guix repl
command makes it easier to program Guix in Guile by
launching a Guile read-eval-print loop (REPL) for interactive
programming (veja Using Guile Interactively em GNU Guile Reference
Manual), or by running Guile scripts (veja Running Guile Scripts em GNU Guile Reference Manual). Compared to just launching the
guile
command, guix repl
guarantees that all the Guix
modules and all its dependencies are available in the search path.
A sintaxe geral é:
guix repl options [file args]
When a file argument is provided, file is executed as a Guile scripts:
guix repl my-script.scm
To pass arguments to the script, use --
to prevent them from being
interpreted as arguments to guix repl
itself:
guix repl -- my-script.scm --input=foo.txt
To make a script executable directly from the shell, using the guix executable that is on the user’s search path, add the following two lines at the top of the script:
#!/usr/bin/env -S guix repl --
!#
To make a script that launches an interactive REPL directly from the shell,
use the --interactive
flag:
#!/usr/bin/env -S guix repl --interactive
!#
Without a file name argument, a Guile REPL is started, allowing for interactive use (veja Using Guix Interactively):
$ guix repl scheme@(guile-user)> ,use (gnu packages base) scheme@(guile-user)> coreutils $1 = #<package coreutils@8.29 gnu/packages/base.scm:327 3e28300>
In addition, guix repl
implements a simple machine-readable REPL
protocol for use by (guix inferior)
, a facility to interact with
inferiors, separate processes running a potentially different revision
of Guix.
As opções disponíveis são as seguintes:
--list-types
Display the TYPE options for guix repl --type=TYPE
and exit.
--type=type
-t tipo
Start a REPL of the given TYPE, which can be one of the following:
guile
This is default, and it spawns a standard full-featured Guile REPL.
machine
Spawn a REPL that uses the machine-readable protocol. This is the protocol
that the (guix inferior)
module speaks.
--listen=endpoint
By default, guix repl
reads from standard input and writes to
standard output. When this option is passed, it will instead listen for
connections on endpoint. Here are examples of valid options:
--listen=tcp:37146
Accept connections on localhost on port 37146.
--listen=unix:/tmp/socket
Accept connections on the Unix-domain socket /tmp/socket.
--interactive
-i
Launch the interactive REPL after file is executed.
--load-path=directory
-L diretório
Add directory to the front of the package module search path (veja Módulos de pacote).
This allows users to define their own packages and make them visible to the script or REPL.
-q
Inhibit loading of the ~/.guile file. By default, that configuration
file is loaded when spawning a guile
REPL.
Próximo: Using Guix Interactively, Anterior: Expressões-G, Acima: Interface de programação [Conteúdo][Índice]