Ludovic Courtès <[email protected]> writes:
The first step would be to define an <environment> record to
describe
all these aspects we talked about.
Perhaps something like:
;; First step definition of an <environment> record for (guix
scripts shell).
;;
;; The intent is that <environment> captures the aspects of “guix
shell”
;; that are not already represented by manifests: purity,
containers,
;; filesystem view, and environment variables. Build/daemon
options
;; (-c, -M, --no-substitutes, --system, etc.) are deliberately
left out.
(define-record-type* <shared-directory>
shared-directory make-shared-directory shared-directory?
;; Host file name, e.g. "/src" or ".".
(source shared-directory-source)
;; File name inside the environment/container, e.g. "/work".
(target shared-directory-target)
;; #t → writable share (like --share), #f → read-only (like
--expose).
(writable? shared-directory-writable?
(default #t)))
(define-record-type* <environment>
environment make-environment environment?
;; Optional manifest for this environment. When non-#f, this is
the
;; manifest that “guix shell” should use instead of, or in
addition to,
;; the usual -m/-f/-e/PKGS parsing.
(manifest environment-manifest
(default #f))
;; Equivalent to --pure.
(pure? environment-pure?
(default #f))
;; Equivalent to --container.
(container? environment-container?
(default #f))
;; Equivalent to -F / --emulate-fhs.
(emulate-fhs? environment-emulate-fhs?
(default #f))
;; Network policy for containers; e.g. 'inherit (current
default),
;; 'allow (like -N / --network), or 'none (no network access).
(network environment-network
(default 'inherit))
;; Whether the container’s root file system is writable
;; (--writable-root).
(writable-root? environment-writable-root?
(default #f))
;; Whether to share the current working directory with the
container.
;; This is the opposite of --no-cwd; the default matches current
;; behaviour.
(share-cwd? environment-share-cwd?
(default #t))
;; Whether to link the environment profile to ~/.guix-profile
inside
;; the container (-P / --link-profile).
(link-profile? environment-link-profile?
(default #f))
;; Whether Guix itself should be available within the container
;; (-W / --nesting).
(nesting? environment-nesting?
(default #f))
;; Optional user name to use inside the container (-u / --user).
(user environment-user
(default #f))
;; Additional host directories to make visible inside the
environment,
;; on top of CWD sharing. Maps to --share / --expose.
(shared-directories environment-shared-directories
(default '()))
;; Container symlinks as produced by -S / --symlink. For now
these are
;; kept as raw SPEC strings, e.g. "/usr/bin/env=bin/env".
(symlinks environment-symlinks
(default '()))
;; Environment variables that should be preserved from the
incoming
;; process environment. Each string is interpreted as a
variable name;
;; internally this can correspond to --preserve='^NAME$'.
(preserved-variables environment-preserved-variables
(default '()))
;; Optional list of regular expressions corresponding to -E /
--preserve=REGEXP
;; on the command line. This allows representing the full
expressiveness
;; of the CLI when constructing an <environment> from argv.
(preserved-regexps environment-preserved-regexps
(default '()))
;; Extra environment variables to define or override inside the
shell
;; or container. Each element is a (NAME . VALUE) pair.
(variables environment-variables
(default '())))