2014-09-21 13:40:05 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2018-02-15 20:54:28 -05:00
|
|
|
|
;;; Copyright © 2014, 2015, 2018 David Thompson <davet@gnu.org>
|
2018-07-09 07:00:46 -04:00
|
|
|
|
;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
|
2018-01-25 22:29:15 -05:00
|
|
|
|
;;; Copyright © 2018 Mike Gerwitz <mtg@gnu.org>
|
2014-09-21 13:40:05 -04:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (guix scripts environment)
|
|
|
|
|
#:use-module (guix ui)
|
|
|
|
|
#:use-module (guix store)
|
2017-01-18 17:21:29 -05:00
|
|
|
|
#:use-module (guix status)
|
2016-03-02 07:43:13 -05:00
|
|
|
|
#:use-module (guix grafts)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
#:use-module (guix derivations)
|
|
|
|
|
#:use-module (guix packages)
|
|
|
|
|
#:use-module (guix profiles)
|
2015-05-05 04:59:26 -04:00
|
|
|
|
#:use-module (guix search-paths)
|
2015-06-19 08:57:44 -04:00
|
|
|
|
#:use-module (guix build utils)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
#:use-module (guix monads)
|
2015-06-30 17:23:06 -04:00
|
|
|
|
#:use-module ((guix gexp) #:select (lower-inputs))
|
2015-09-10 05:37:36 -04:00
|
|
|
|
#:use-module (guix scripts)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
#:use-module (guix scripts build)
|
2015-06-19 08:57:44 -04:00
|
|
|
|
#:use-module (gnu build linux-container)
|
|
|
|
|
#:use-module (gnu system linux-container)
|
|
|
|
|
#:use-module (gnu system file-systems)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
#:use-module (gnu packages)
|
2015-06-19 08:57:44 -04:00
|
|
|
|
#:use-module (gnu packages bash)
|
2016-02-12 15:39:26 -05:00
|
|
|
|
#:use-module (gnu packages commencement)
|
|
|
|
|
#:use-module (gnu packages guile)
|
|
|
|
|
#:use-module ((gnu packages bootstrap) #:select (%bootstrap-guile))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
#:use-module (ice-9 format)
|
|
|
|
|
#:use-module (ice-9 match)
|
2015-06-19 08:57:44 -04:00
|
|
|
|
#:use-module (ice-9 rdelim)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
#:use-module (srfi srfi-1)
|
2015-06-30 17:16:42 -04:00
|
|
|
|
#:use-module (srfi srfi-11)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
#:use-module (srfi srfi-26)
|
|
|
|
|
#:use-module (srfi srfi-37)
|
|
|
|
|
#:use-module (srfi srfi-98)
|
|
|
|
|
#:export (guix-environment))
|
|
|
|
|
|
|
|
|
|
;; Protect some env vars from purification. Borrowed from nix-shell.
|
|
|
|
|
(define %precious-variables
|
|
|
|
|
'("HOME" "USER" "LOGNAME" "DISPLAY" "TERM" "TZ" "PAGER"))
|
|
|
|
|
|
2015-10-09 12:11:24 -04:00
|
|
|
|
(define %default-shell
|
|
|
|
|
(or (getenv "SHELL") "/bin/sh"))
|
|
|
|
|
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(define (purify-environment)
|
|
|
|
|
"Unset almost all environment variables. A small number of variables such
|
|
|
|
|
as 'HOME' and 'USER' are left untouched."
|
|
|
|
|
(for-each unsetenv
|
|
|
|
|
(remove (cut member <> %precious-variables)
|
|
|
|
|
(match (get-environment-variables)
|
|
|
|
|
(((names . _) ...)
|
|
|
|
|
names)))))
|
|
|
|
|
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(define* (create-environment profile manifest #:key pure?)
|
|
|
|
|
"Set the environment variables specified by MANIFEST for PROFILE. When PURE?
|
2016-02-12 15:39:26 -05:00
|
|
|
|
is #t, unset the variables in the current environment. Otherwise, augment
|
2017-05-03 15:38:57 -04:00
|
|
|
|
existing environment variables with additional search paths."
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(when pure? (purify-environment))
|
2015-05-05 09:02:35 -04:00
|
|
|
|
(for-each (match-lambda
|
|
|
|
|
((($ <search-path-specification> variable _ separator) . value)
|
|
|
|
|
(let ((current (getenv variable)))
|
|
|
|
|
(setenv variable
|
|
|
|
|
(if (and current (not pure?))
|
2017-04-05 16:50:21 -04:00
|
|
|
|
(if separator
|
|
|
|
|
(string-append value separator current)
|
|
|
|
|
value)
|
2015-05-05 09:02:35 -04:00
|
|
|
|
value)))))
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(profile-search-paths profile manifest))
|
2015-07-01 08:39:14 -04:00
|
|
|
|
|
|
|
|
|
;; Give users a way to know that they're in 'guix environment', so they can
|
2016-07-26 11:59:25 -04:00
|
|
|
|
;; adjust 'PS1' accordingly, for instance. Set it to PROFILE so users can
|
|
|
|
|
;; conveniently access its contents.
|
|
|
|
|
(setenv "GUIX_ENVIRONMENT" profile))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(define* (show-search-paths profile manifest #:key pure?)
|
|
|
|
|
"Display the search paths of MANIFEST applied to PROFILE. When PURE? is #t,
|
|
|
|
|
do not augment existing environment variables with additional search paths."
|
2015-05-05 09:02:35 -04:00
|
|
|
|
(for-each (match-lambda
|
|
|
|
|
((search-path . value)
|
|
|
|
|
(display
|
|
|
|
|
(search-path-definition search-path value
|
|
|
|
|
#:kind (if pure? 'exact 'prefix)))
|
|
|
|
|
(newline)))
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(profile-search-paths profile manifest)))
|
2016-02-12 15:39:26 -05:00
|
|
|
|
|
2018-07-09 07:00:46 -04:00
|
|
|
|
(define (input->manifest-entry input)
|
|
|
|
|
"Return a manifest entry for INPUT, or #f if INPUT does not correspond to a
|
|
|
|
|
package."
|
2016-02-12 15:39:26 -05:00
|
|
|
|
(match input
|
2018-07-09 07:00:46 -04:00
|
|
|
|
((_ (? package? package))
|
|
|
|
|
(package->manifest-entry package))
|
|
|
|
|
((_ (? package? package) output)
|
|
|
|
|
(package->manifest-entry package output))
|
|
|
|
|
(_
|
|
|
|
|
#f)))
|
2016-02-12 15:39:26 -05:00
|
|
|
|
|
|
|
|
|
(define (package-environment-inputs package)
|
2018-07-09 07:00:46 -04:00
|
|
|
|
"Return a list of manifest entries corresponding to the transitive input
|
|
|
|
|
packages for PACKAGE."
|
2016-02-12 15:39:26 -05:00
|
|
|
|
;; Remove non-package inputs such as origin records.
|
2018-07-09 07:00:46 -04:00
|
|
|
|
(filter-map input->manifest-entry
|
|
|
|
|
(bag-transitive-inputs (package->bag package))))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
|
|
|
|
|
(define (show-help)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "Usage: guix environment [OPTION]... PACKAGE... [-- COMMAND...]
|
2015-10-09 12:11:24 -04:00
|
|
|
|
Build an environment that includes the dependencies of PACKAGE and execute
|
|
|
|
|
COMMAND or an interactive shell in that environment.\n"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2014-09-21 13:40:05 -04:00
|
|
|
|
-e, --expression=EXPR create environment for the package that EXPR
|
|
|
|
|
evaluates to"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2014-09-21 13:40:05 -04:00
|
|
|
|
-l, --load=FILE create environment for the package that the code within
|
|
|
|
|
FILE evaluates to"))
|
2018-02-15 20:54:28 -05:00
|
|
|
|
(display (G_ "
|
|
|
|
|
-m, --manifest=FILE create environment with the manifest from FILE"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-05-28 08:41:04 -04:00
|
|
|
|
--ad-hoc include all specified packages in the environment instead
|
|
|
|
|
of only their inputs"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2014-10-29 18:40:17 -04:00
|
|
|
|
--pure unset existing environment variables"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2014-10-29 18:40:17 -04:00
|
|
|
|
--search-paths display needed environment variable definitions"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-06-30 11:42:35 -04:00
|
|
|
|
-s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2016-12-20 13:06:22 -05:00
|
|
|
|
-r, --root=FILE make FILE a symlink to the result, and register it
|
|
|
|
|
as a garbage collector root"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-06-19 08:57:44 -04:00
|
|
|
|
-C, --container run command within an isolated container"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-06-19 08:57:44 -04:00
|
|
|
|
-N, --network allow containers to access the network"))
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(display (G_ "
|
|
|
|
|
-P, --link-profile link environment profile to ~/.guix-profile within
|
|
|
|
|
an isolated container"))
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(display (G_ "
|
|
|
|
|
-u, --user=USER instead of copying the name and home of the current
|
|
|
|
|
user into an isolated container, use the name USER
|
|
|
|
|
with home directory /home/USER"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-06-19 08:57:44 -04:00
|
|
|
|
--share=SPEC for containers, share writable host file system
|
|
|
|
|
according to SPEC"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-06-19 08:57:44 -04:00
|
|
|
|
--expose=SPEC for containers, expose read-only host file system
|
|
|
|
|
according to SPEC"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2015-06-19 08:57:44 -04:00
|
|
|
|
--bootstrap use bootstrap binaries to build the environment"))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(newline)
|
|
|
|
|
(show-build-options-help)
|
|
|
|
|
(newline)
|
2018-12-17 16:47:44 -05:00
|
|
|
|
(show-transformation-options-help)
|
|
|
|
|
(newline)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2014-09-21 13:40:05 -04:00
|
|
|
|
-h, --help display this help and exit"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(display (G_ "
|
2014-09-21 13:40:05 -04:00
|
|
|
|
-V, --version display version information and exit"))
|
2014-10-29 18:40:17 -04:00
|
|
|
|
(newline)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(show-bug-report-information))
|
|
|
|
|
|
|
|
|
|
(define %default-options
|
2015-11-01 18:34:53 -05:00
|
|
|
|
`((system . ,(%current-system))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(substitutes? . #t)
|
2017-12-07 16:49:08 -05:00
|
|
|
|
(build-hook? . #t)
|
2016-03-02 07:43:13 -05:00
|
|
|
|
(graft? . #t)
|
2017-01-18 17:21:29 -05:00
|
|
|
|
(print-build-trace? . #t)
|
|
|
|
|
(print-extended-build-trace? . #t)
|
2018-10-15 17:06:55 -04:00
|
|
|
|
(multiplexed-build-output? . #t)
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(verbosity . 0)))
|
|
|
|
|
|
2015-10-25 22:33:33 -04:00
|
|
|
|
(define (tag-package-arg opts arg)
|
|
|
|
|
"Return a two-element list with the form (TAG ARG) that tags ARG with either
|
|
|
|
|
'ad-hoc' in OPTS has the 'ad-hoc?' key set to #t, or 'inputs' otherwise."
|
|
|
|
|
;; Normally, the transitive inputs to a package are added to an environment,
|
|
|
|
|
;; but the ad-hoc? flag changes the meaning of a package argument such that
|
|
|
|
|
;; the package itself is added to the environment instead.
|
|
|
|
|
(if (assoc-ref opts 'ad-hoc?)
|
|
|
|
|
`(ad-hoc-package ,arg)
|
|
|
|
|
`(package ,arg)))
|
|
|
|
|
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(define %options
|
|
|
|
|
;; Specification of the command-line options.
|
|
|
|
|
(cons* (option '(#\h "help") #f #f
|
|
|
|
|
(lambda args
|
|
|
|
|
(show-help)
|
|
|
|
|
(exit 0)))
|
|
|
|
|
(option '(#\V "version") #f #f
|
|
|
|
|
(lambda args
|
|
|
|
|
(show-version-and-exit "guix environment")))
|
|
|
|
|
(option '("pure") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'pure #t result)))
|
2015-10-09 12:11:24 -04:00
|
|
|
|
(option '(#\E "exec") #t #f ; deprecated
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(lambda (opt name arg result)
|
2015-10-09 12:11:24 -04:00
|
|
|
|
(alist-cons 'exec (list %default-shell "-c" arg) result)))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(option '("search-paths") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'search-paths #t result)))
|
|
|
|
|
(option '(#\l "load") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
2015-10-25 22:33:33 -04:00
|
|
|
|
(alist-cons 'load
|
|
|
|
|
(tag-package-arg result arg)
|
|
|
|
|
result)))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(option '(#\e "expression") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
2015-10-25 22:33:33 -04:00
|
|
|
|
(alist-cons 'expression
|
|
|
|
|
(tag-package-arg result arg)
|
|
|
|
|
result)))
|
2018-02-15 20:54:28 -05:00
|
|
|
|
(option '(#\m "manifest") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'manifest
|
|
|
|
|
arg
|
|
|
|
|
result)))
|
2015-05-28 08:41:04 -04:00
|
|
|
|
(option '("ad-hoc") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'ad-hoc? #t result)))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(option '(#\n "dry-run") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
2016-08-28 10:22:19 -04:00
|
|
|
|
(alist-cons 'dry-run? #t (alist-cons 'graft? #f result))))
|
2015-06-30 11:42:35 -04:00
|
|
|
|
(option '(#\s "system") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'system arg
|
|
|
|
|
(alist-delete 'system result eq?))))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(option '(#\C "container") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'container? #t result)))
|
|
|
|
|
(option '(#\N "network") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'network? #t result)))
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(option '(#\P "link-profile") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'link-profile? #t result)))
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(option '(#\u "user") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'user arg
|
|
|
|
|
(alist-delete 'user result eq?))))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(option '("share") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'file-system-mapping
|
|
|
|
|
(specification->file-system-mapping arg #t)
|
|
|
|
|
result)))
|
|
|
|
|
(option '("expose") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'file-system-mapping
|
|
|
|
|
(specification->file-system-mapping arg #f)
|
|
|
|
|
result)))
|
2016-12-20 13:06:22 -05:00
|
|
|
|
(option '(#\r "root") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'gc-root arg result)))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(option '("bootstrap") #f #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'bootstrap? #t result)))
|
2018-12-17 16:47:44 -05:00
|
|
|
|
|
|
|
|
|
(append %transformation-options
|
|
|
|
|
%standard-build-options)))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
|
|
|
|
|
(define (pick-all alist key)
|
|
|
|
|
"Return a list of values in ALIST associated with KEY."
|
|
|
|
|
(define same-key? (cut eq? key <>))
|
|
|
|
|
|
|
|
|
|
(fold (lambda (pair memo)
|
|
|
|
|
(match pair
|
|
|
|
|
(((? same-key? k) . v)
|
|
|
|
|
(cons v memo))
|
|
|
|
|
(_ memo)))
|
|
|
|
|
'() alist))
|
|
|
|
|
|
2018-12-17 16:47:44 -05:00
|
|
|
|
(define (options/resolve-packages store opts)
|
2018-07-09 07:00:46 -04:00
|
|
|
|
"Return OPTS with package specification strings replaced by manifest entries
|
|
|
|
|
for the corresponding packages."
|
|
|
|
|
(define (manifest-entry=? e1 e2)
|
|
|
|
|
(and (eq? (manifest-entry-item e1) (manifest-entry-item e2))
|
|
|
|
|
(string=? (manifest-entry-output e1)
|
|
|
|
|
(manifest-entry-output e2))))
|
2015-10-30 21:02:51 -04:00
|
|
|
|
|
2018-12-17 16:47:44 -05:00
|
|
|
|
(define transform
|
|
|
|
|
(cut (options->transformation opts) store <>))
|
|
|
|
|
|
|
|
|
|
(define* (package->manifest-entry* package #:optional (output "out"))
|
|
|
|
|
(package->manifest-entry (transform package) output))
|
|
|
|
|
|
2015-10-30 21:02:51 -04:00
|
|
|
|
(define (packages->outputs packages mode)
|
|
|
|
|
(match packages
|
2018-07-09 07:00:46 -04:00
|
|
|
|
((? package? package)
|
|
|
|
|
(if (eq? mode 'ad-hoc-package)
|
2018-12-17 16:47:44 -05:00
|
|
|
|
(list (package->manifest-entry* package))
|
2018-07-09 07:00:46 -04:00
|
|
|
|
(package-environment-inputs package)))
|
|
|
|
|
(((? package? package) (? string? output))
|
|
|
|
|
(if (eq? mode 'ad-hoc-package)
|
2018-12-17 16:47:44 -05:00
|
|
|
|
(list (package->manifest-entry* package output))
|
2018-07-09 07:00:46 -04:00
|
|
|
|
(package-environment-inputs package)))
|
|
|
|
|
((lst ...)
|
|
|
|
|
(append-map (cut packages->outputs <> mode) lst))))
|
|
|
|
|
|
|
|
|
|
(manifest
|
|
|
|
|
(delete-duplicates
|
|
|
|
|
(append-map (match-lambda
|
|
|
|
|
(('package 'ad-hoc-package (? string? spec))
|
|
|
|
|
(let-values (((package output)
|
|
|
|
|
(specification->package+output spec)))
|
2018-12-17 16:47:44 -05:00
|
|
|
|
(list (package->manifest-entry* package output))))
|
2018-07-09 07:00:46 -04:00
|
|
|
|
(('package 'package (? string? spec))
|
|
|
|
|
(package-environment-inputs
|
|
|
|
|
(specification->package+output spec)))
|
|
|
|
|
(('expression mode str)
|
|
|
|
|
;; Add all the outputs of the package STR evaluates to.
|
|
|
|
|
(packages->outputs (read/eval str) mode))
|
|
|
|
|
(('load mode file)
|
|
|
|
|
;; Add all the outputs of the package defined in FILE.
|
|
|
|
|
(let ((module (make-user-module '())))
|
|
|
|
|
(packages->outputs (load* file module) mode)))
|
|
|
|
|
(('manifest . file)
|
|
|
|
|
(let ((module (make-user-module '((guix profiles) (gnu)))))
|
|
|
|
|
(manifest-entries (load* file module))))
|
|
|
|
|
(_ '()))
|
|
|
|
|
opts)
|
|
|
|
|
manifest-entry=?)))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
|
2016-02-12 15:39:26 -05:00
|
|
|
|
(define* (build-environment derivations opts)
|
|
|
|
|
"Build the DERIVATIONS required by the environment using the build options
|
|
|
|
|
in OPTS."
|
2014-09-21 13:40:05 -04:00
|
|
|
|
(let ((substitutes? (assoc-ref opts 'substitutes?))
|
2015-06-30 17:23:06 -04:00
|
|
|
|
(dry-run? (assoc-ref opts 'dry-run?)))
|
2016-02-12 15:39:26 -05:00
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(show-what-to-build* derivations
|
|
|
|
|
#:use-substitutes? substitutes?
|
|
|
|
|
#:dry-run? dry-run?)
|
|
|
|
|
(if dry-run?
|
|
|
|
|
(return #f)
|
2017-07-12 06:04:55 -04:00
|
|
|
|
(built-derivations derivations)))))
|
2016-02-12 15:39:26 -05:00
|
|
|
|
|
2018-07-09 07:00:46 -04:00
|
|
|
|
(define (manifest->derivation manifest system bootstrap?)
|
|
|
|
|
"Return the derivation for a profile of MANIFEST.
|
|
|
|
|
BOOTSTRAP? specifies whether to use the bootstrap Guile to build the profile."
|
|
|
|
|
(profile-derivation manifest
|
2016-02-12 15:39:26 -05:00
|
|
|
|
#:system system
|
2017-06-21 10:50:59 -04:00
|
|
|
|
|
|
|
|
|
;; Packages can have conflicting inputs, or explicit
|
|
|
|
|
;; inputs that conflict with implicit inputs (e.g., gcc,
|
|
|
|
|
;; gzip, etc.). Thus, do not error out when we
|
|
|
|
|
;; encounter collision.
|
|
|
|
|
#:allow-collisions? #t
|
|
|
|
|
|
2016-02-12 15:39:26 -05:00
|
|
|
|
#:hooks (if bootstrap?
|
|
|
|
|
'()
|
2016-12-17 06:43:10 -05:00
|
|
|
|
%default-profile-hooks)
|
|
|
|
|
#:locales? (not bootstrap?)))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(define requisites* (store-lift requisites))
|
|
|
|
|
|
|
|
|
|
(define (inputs->requisites inputs)
|
|
|
|
|
"Convert INPUTS, a list of input tuples or store path strings, into a set of
|
|
|
|
|
requisite store items i.e. the union closure of all the inputs."
|
|
|
|
|
(define (input->requisites input)
|
|
|
|
|
(requisites*
|
|
|
|
|
(match input
|
|
|
|
|
((drv output)
|
2016-05-24 17:27:07 -04:00
|
|
|
|
(list (derivation->output-path drv output)))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
((drv)
|
2016-05-24 17:27:07 -04:00
|
|
|
|
(list (derivation->output-path drv)))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
((? direct-store-path? path)
|
2016-05-24 17:27:07 -04:00
|
|
|
|
(list path)))))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
|
|
|
|
|
(mlet %store-monad ((reqs (sequence %store-monad
|
|
|
|
|
(map input->requisites inputs))))
|
|
|
|
|
(return (delete-duplicates (concatenate reqs)))))
|
|
|
|
|
|
2015-11-21 16:24:45 -05:00
|
|
|
|
(define (status->exit-code status)
|
|
|
|
|
"Compute the exit code made from STATUS, a value as returned by 'waitpid',
|
|
|
|
|
and suitable for 'exit'."
|
|
|
|
|
;; See <bits/waitstatus.h>.
|
|
|
|
|
(or (status:exit-val status)
|
|
|
|
|
(logior #x80 (status:term-sig status))))
|
|
|
|
|
|
|
|
|
|
(define exit/status (compose exit status->exit-code))
|
|
|
|
|
(define primitive-exit/status (compose primitive-exit status->exit-code))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(define* (launch-environment command profile manifest
|
|
|
|
|
#:key pure?)
|
2015-06-19 08:57:44 -04:00
|
|
|
|
"Run COMMAND in a new environment containing INPUTS, using the native search
|
|
|
|
|
paths defined by the list PATHS. When PURE?, pre-existing environment
|
|
|
|
|
variables are cleared before setting the new ones."
|
2016-03-26 08:45:08 -04:00
|
|
|
|
;; Properly handle SIGINT, so pressing C-c in an interactive terminal
|
|
|
|
|
;; application works.
|
|
|
|
|
(sigaction SIGINT SIG_DFL)
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(create-environment profile manifest #:pure? pure?)
|
2016-03-26 08:45:08 -04:00
|
|
|
|
(match command
|
|
|
|
|
((program . args)
|
|
|
|
|
(apply execlp program program args))))
|
|
|
|
|
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(define* (launch-environment/fork command profile manifest #:key pure?)
|
|
|
|
|
"Run COMMAND in a new process with an environment containing PROFILE, with
|
|
|
|
|
the search paths specified by MANIFEST. When PURE?, pre-existing environment
|
|
|
|
|
variables are cleared before setting the new ones."
|
2016-03-26 08:45:08 -04:00
|
|
|
|
(match (primitive-fork)
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(0 (launch-environment command profile manifest
|
|
|
|
|
#:pure? pure?))
|
2016-03-26 08:45:08 -04:00
|
|
|
|
(pid (match (waitpid pid)
|
|
|
|
|
((_ . status) status)))))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(define* (launch-environment/container #:key command bash user user-mappings
|
2018-07-09 07:22:29 -04:00
|
|
|
|
profile manifest link-profile? network?)
|
2016-02-12 15:39:26 -05:00
|
|
|
|
"Run COMMAND within a container that features the software in PROFILE.
|
2018-07-09 07:22:29 -04:00
|
|
|
|
Environment variables are set according to the search paths of MANIFEST.
|
|
|
|
|
The global shell is BASH, a file name for a GNU Bash binary in the
|
2016-02-12 15:39:26 -05:00
|
|
|
|
store. When NETWORK?, access to the host system network is permitted.
|
|
|
|
|
USER-MAPPINGS, a list of file system mappings, contains the user-specified
|
2018-01-25 22:29:32 -05:00
|
|
|
|
host file systems to mount inside the container. If USER is not #f, each
|
|
|
|
|
target of USER-MAPPINGS will be re-written relative to '/home/USER', and USER
|
|
|
|
|
will be used for the passwd entry. LINK-PROFILE? creates a symbolic link from
|
|
|
|
|
~/.guix-profile to the environment profile."
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(mlet %store-monad ((reqs (inputs->requisites
|
2016-02-12 15:39:26 -05:00
|
|
|
|
(list (direct-store-path bash) profile))))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(return
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(let* ((cwd (getcwd))
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(home (getenv "HOME"))
|
|
|
|
|
(passwd (mock-passwd (getpwuid (getuid))
|
|
|
|
|
user
|
|
|
|
|
bash))
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(home-dir (passwd:dir passwd))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
;; Bind-mount all requisite store items, user-specified mappings,
|
|
|
|
|
;; /bin/sh, the current working directory, and possibly networking
|
|
|
|
|
;; configuration files within the container.
|
|
|
|
|
(mappings
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(override-user-mappings
|
|
|
|
|
user home
|
|
|
|
|
(append user-mappings
|
|
|
|
|
;; Current working directory.
|
|
|
|
|
(list (file-system-mapping
|
|
|
|
|
(source cwd)
|
|
|
|
|
(target cwd)
|
|
|
|
|
(writable? #t)))
|
|
|
|
|
;; When in Rome, do as Nix build.cc does: Automagically
|
|
|
|
|
;; map common network configuration files.
|
|
|
|
|
(if network?
|
|
|
|
|
%network-file-mappings
|
|
|
|
|
'())
|
|
|
|
|
;; Mappings for the union closure of all inputs.
|
|
|
|
|
(map (lambda (dir)
|
|
|
|
|
(file-system-mapping
|
|
|
|
|
(source dir)
|
|
|
|
|
(target dir)
|
|
|
|
|
(writable? #f)))
|
|
|
|
|
reqs))))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(file-systems (append %container-file-systems
|
2017-02-02 18:20:40 -05:00
|
|
|
|
(map file-system-mapping->bind-mount
|
|
|
|
|
mappings))))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(exit/status
|
2016-11-10 11:45:54 -05:00
|
|
|
|
(call-with-container file-systems
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(lambda ()
|
|
|
|
|
;; Setup global shell.
|
|
|
|
|
(mkdir-p "/bin")
|
|
|
|
|
(symlink bash "/bin/sh")
|
|
|
|
|
|
2016-03-27 21:20:19 -04:00
|
|
|
|
;; Set a reasonable default PS1.
|
|
|
|
|
(setenv "PS1" "\\u@\\h \\w [env]\\$ ")
|
|
|
|
|
|
2015-06-19 08:57:44 -04:00
|
|
|
|
;; Setup directory for temporary files.
|
|
|
|
|
(mkdir-p "/tmp")
|
|
|
|
|
(for-each (lambda (var)
|
|
|
|
|
(setenv var "/tmp"))
|
|
|
|
|
;; The same variables as in Nix's 'build.cc'.
|
|
|
|
|
'("TMPDIR" "TEMPDIR" "TMP" "TEMP"))
|
|
|
|
|
|
2018-01-25 22:29:32 -05:00
|
|
|
|
;; Create a dummy home directory.
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(mkdir-p home-dir)
|
|
|
|
|
(setenv "HOME" home-dir)
|
|
|
|
|
|
|
|
|
|
;; If requested, link $GUIX_ENVIRONMENT to $HOME/.guix-profile;
|
|
|
|
|
;; this allows programs expecting that path to continue working as
|
|
|
|
|
;; expected within a container.
|
|
|
|
|
(when link-profile? (link-environment profile home-dir))
|
2016-03-17 23:19:25 -04:00
|
|
|
|
|
|
|
|
|
;; Create a dummy /etc/passwd to satisfy applications that demand
|
|
|
|
|
;; to read it, such as 'git clone' over SSH, a valid use-case when
|
|
|
|
|
;; sharing the host's network namespace.
|
|
|
|
|
(mkdir-p "/etc")
|
|
|
|
|
(call-with-output-file "/etc/passwd"
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(display (string-join (list (passwd:name passwd)
|
|
|
|
|
"x" ; but there is no shadow
|
|
|
|
|
"0" "0" ; user is now root
|
|
|
|
|
(passwd:gecos passwd)
|
|
|
|
|
(passwd:dir passwd)
|
|
|
|
|
bash)
|
|
|
|
|
":")
|
|
|
|
|
port)
|
|
|
|
|
(newline port)))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
|
|
|
|
|
;; For convenience, start in the user's current working
|
|
|
|
|
;; directory rather than the root directory.
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(chdir (override-user-dir user home cwd))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
|
|
|
|
|
(primitive-exit/status
|
|
|
|
|
;; A container's environment is already purified, so no need to
|
|
|
|
|
;; request it be purified again.
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(launch-environment command profile manifest #:pure? #f)))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
#:namespaces (if network?
|
|
|
|
|
(delq 'net %namespaces) ; share host network
|
|
|
|
|
%namespaces)))))))
|
|
|
|
|
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(define (mock-passwd passwd user-override shell)
|
|
|
|
|
"Generate mock information for '/etc/passwd'. If USER-OVERRIDE is not '#f',
|
|
|
|
|
it is expected to be a string representing the mock username; it will produce
|
|
|
|
|
a user of that name, with a home directory of '/home/USER-OVERRIDE', and no
|
|
|
|
|
GECOS field. If USER-OVERRIDE is '#f', data will be inherited from PASSWD.
|
|
|
|
|
In either case, the shadow password and UID/GID are cleared, since the user
|
|
|
|
|
runs as root within the container. SHELL will always be used in place of the
|
|
|
|
|
shell in PASSWD.
|
|
|
|
|
|
|
|
|
|
The resulting vector is suitable for use with Guile's POSIX user procedures.
|
|
|
|
|
|
|
|
|
|
See passwd(5) for more information each of the fields."
|
|
|
|
|
(if user-override
|
|
|
|
|
(vector
|
|
|
|
|
user-override
|
|
|
|
|
"x" "0" "0" ;; no shadow, user is now root
|
|
|
|
|
"" ;; no personal information
|
|
|
|
|
(user-override-home user-override)
|
|
|
|
|
shell)
|
|
|
|
|
(vector
|
|
|
|
|
(passwd:name passwd)
|
|
|
|
|
"x" "0" "0" ;; no shadow, user is now root
|
|
|
|
|
(passwd:gecos passwd)
|
|
|
|
|
(passwd:dir passwd)
|
|
|
|
|
shell)))
|
|
|
|
|
|
|
|
|
|
(define (user-override-home user)
|
|
|
|
|
"Return home directory for override user USER."
|
|
|
|
|
(string-append "/home/" user))
|
|
|
|
|
|
|
|
|
|
(define (override-user-mappings user home mappings)
|
|
|
|
|
"If a username USER is provided, rewrite each HOME prefix in file system
|
|
|
|
|
mappings MAPPINGS to a home directory determined by 'override-user-dir';
|
|
|
|
|
otherwise, return MAPPINGS."
|
|
|
|
|
(if (not user)
|
|
|
|
|
mappings
|
|
|
|
|
(map (lambda (mapping)
|
|
|
|
|
(let ((target (file-system-mapping-target mapping)))
|
|
|
|
|
(if (string-prefix? home target)
|
|
|
|
|
(file-system-mapping
|
|
|
|
|
(source (file-system-mapping-source mapping))
|
|
|
|
|
(target (override-user-dir user home target))
|
|
|
|
|
(writable? (file-system-mapping-writable? mapping)))
|
|
|
|
|
mapping)))
|
|
|
|
|
mappings)))
|
|
|
|
|
|
|
|
|
|
(define (override-user-dir user home dir)
|
|
|
|
|
"If username USER is provided, overwrite string prefix HOME in DIR with a
|
|
|
|
|
directory determined by 'user-override-home'; otherwise, return DIR."
|
|
|
|
|
(if (and user (string-prefix? home dir))
|
|
|
|
|
(string-append (user-override-home user)
|
|
|
|
|
(substring dir (string-length home)))
|
|
|
|
|
dir))
|
|
|
|
|
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(define (link-environment profile home-dir)
|
|
|
|
|
"Create a symbolic link from HOME-DIR/.guix-profile to PROFILE."
|
|
|
|
|
(let ((profile-dir (string-append home-dir "/.guix-profile")))
|
|
|
|
|
(catch 'system-error
|
|
|
|
|
(lambda ()
|
|
|
|
|
(symlink profile profile-dir))
|
|
|
|
|
(lambda args
|
|
|
|
|
(if (= EEXIST (system-error-errno args))
|
|
|
|
|
(leave (G_ "cannot link profile: '~a' already exists within container~%")
|
|
|
|
|
profile-dir)
|
|
|
|
|
(apply throw args))))))
|
|
|
|
|
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(define (environment-bash container? bootstrap? system)
|
|
|
|
|
"Return a monadic value in the store monad for the version of GNU Bash
|
|
|
|
|
needed in the environment for SYSTEM, if any. If CONTAINER? is #f, return #f.
|
|
|
|
|
If CONTAINER? and BOOTSTRAP?, return the store path for the bootstrap Bash.
|
|
|
|
|
Otherwise, return the derivation for the Bash package."
|
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(cond
|
|
|
|
|
((and container? (not bootstrap?))
|
|
|
|
|
(package->derivation bash))
|
|
|
|
|
;; Use the bootstrap Bash instead.
|
|
|
|
|
((and container? bootstrap?)
|
|
|
|
|
(interned-file
|
|
|
|
|
(search-bootstrap-binary "bash" system)))
|
|
|
|
|
(else
|
|
|
|
|
(return #f)))))
|
|
|
|
|
|
2015-10-09 12:11:24 -04:00
|
|
|
|
(define (parse-args args)
|
|
|
|
|
"Parse the list of command line arguments ARGS."
|
2015-02-25 17:31:51 -05:00
|
|
|
|
(define (handle-argument arg result)
|
2015-10-25 22:33:33 -04:00
|
|
|
|
(alist-cons 'package (tag-package-arg result arg) result))
|
2014-09-21 13:40:05 -04:00
|
|
|
|
|
2015-10-09 12:11:24 -04:00
|
|
|
|
;; The '--' token is used to separate the command to run from the rest of
|
|
|
|
|
;; the operands.
|
2016-05-04 10:59:31 -04:00
|
|
|
|
(let-values (((args command) (break (cut string=? "--" <>) args)))
|
2015-10-09 12:11:24 -04:00
|
|
|
|
(let ((opts (parse-command-line args %options (list %default-options)
|
|
|
|
|
#:argument-handler handle-argument)))
|
2016-05-04 10:59:31 -04:00
|
|
|
|
(match command
|
|
|
|
|
(() opts)
|
|
|
|
|
(("--") opts)
|
|
|
|
|
(("--" command ...) (alist-cons 'exec command opts))))))
|
2015-10-09 12:11:24 -04:00
|
|
|
|
|
2015-11-03 09:02:10 -05:00
|
|
|
|
(define (assert-container-features)
|
|
|
|
|
"Check if containers can be created and exit with an informative error
|
|
|
|
|
message if any test fails."
|
|
|
|
|
(unless (user-namespace-supported?)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(report-error (G_ "cannot create container: user namespaces unavailable\n"))
|
|
|
|
|
(leave (G_ "is your kernel version < 3.10?\n")))
|
2015-11-03 09:02:10 -05:00
|
|
|
|
|
|
|
|
|
(unless (unprivileged-user-namespace-supported?)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(report-error (G_ "cannot create container: unprivileged user cannot create user namespaces\n"))
|
|
|
|
|
(leave (G_ "please set /proc/sys/kernel/unprivileged_userns_clone to \"1\"\n")))
|
2015-11-03 09:02:10 -05:00
|
|
|
|
|
|
|
|
|
(unless (setgroups-supported?)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(report-error (G_ "cannot create container: /proc/self/setgroups does not exist\n"))
|
|
|
|
|
(leave (G_ "is your kernel version < 3.19?\n"))))
|
2015-11-03 09:02:10 -05:00
|
|
|
|
|
2016-12-20 13:06:22 -05:00
|
|
|
|
(define (register-gc-root target root)
|
|
|
|
|
"Make ROOT an indirect root to TARGET. This is procedure is idempotent."
|
2017-01-18 10:57:56 -05:00
|
|
|
|
(let* ((root (if (string-prefix? "/" root)
|
|
|
|
|
root
|
|
|
|
|
(string-append (canonicalize-path (dirname root))
|
|
|
|
|
"/" root))))
|
2016-12-20 13:06:22 -05:00
|
|
|
|
(catch 'system-error
|
|
|
|
|
(lambda ()
|
|
|
|
|
(symlink target root)
|
|
|
|
|
((store-lift add-indirect-root) root))
|
|
|
|
|
(lambda args
|
|
|
|
|
(if (and (= EEXIST (system-error-errno args))
|
|
|
|
|
(equal? (false-if-exception (readlink root)) target))
|
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(return #t))
|
|
|
|
|
(apply throw args))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Entry point.
|
|
|
|
|
;;;
|
|
|
|
|
|
2015-10-09 12:11:24 -04:00
|
|
|
|
(define (guix-environment . args)
|
2015-03-16 08:59:59 -04:00
|
|
|
|
(with-error-handling
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(let* ((opts (parse-args args))
|
|
|
|
|
(pure? (assoc-ref opts 'pure))
|
|
|
|
|
(container? (assoc-ref opts 'container?))
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(link-prof? (assoc-ref opts 'link-profile?))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(network? (assoc-ref opts 'network?))
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(user (assoc-ref opts 'user))
|
2015-06-19 08:57:44 -04:00
|
|
|
|
(bootstrap? (assoc-ref opts 'bootstrap?))
|
|
|
|
|
(system (assoc-ref opts 'system))
|
2015-11-01 18:34:53 -05:00
|
|
|
|
(command (or (assoc-ref opts 'exec)
|
|
|
|
|
;; Spawn a shell if the user didn't specify
|
|
|
|
|
;; anything in particular.
|
|
|
|
|
(if container?
|
|
|
|
|
;; The user's shell is likely not available
|
|
|
|
|
;; within the container.
|
|
|
|
|
'("/bin/sh")
|
|
|
|
|
(list %default-shell))))
|
2018-07-09 07:22:29 -04:00
|
|
|
|
(mappings (pick-all opts 'file-system-mapping)))
|
2015-11-03 09:02:10 -05:00
|
|
|
|
|
|
|
|
|
(when container? (assert-container-features))
|
|
|
|
|
|
2018-01-25 22:29:15 -05:00
|
|
|
|
(when (and (not container?) link-prof?)
|
|
|
|
|
(leave (G_ "'--link-profile' cannot be used without '--container'~%")))
|
2018-01-25 22:29:32 -05:00
|
|
|
|
(when (and (not container?) user)
|
|
|
|
|
(leave (G_ "'--user' cannot be used without '--container'~%")))
|
2018-01-25 22:29:15 -05:00
|
|
|
|
|
2015-06-11 05:09:12 -04:00
|
|
|
|
(with-store store
|
2017-01-18 17:21:29 -05:00
|
|
|
|
(with-status-report print-build-event
|
2018-12-17 16:47:44 -05:00
|
|
|
|
(define manifest
|
|
|
|
|
(options/resolve-packages store opts))
|
|
|
|
|
|
2017-01-18 17:21:29 -05:00
|
|
|
|
(set-build-options-from-command-line store opts)
|
|
|
|
|
|
|
|
|
|
;; Use the bootstrap Guile when requested.
|
|
|
|
|
(parameterize ((%graft? (assoc-ref opts 'graft?))
|
|
|
|
|
(%guile-for-build
|
|
|
|
|
(package-derivation
|
|
|
|
|
store
|
|
|
|
|
(if bootstrap?
|
|
|
|
|
%bootstrap-guile
|
|
|
|
|
(canonical-package guile-2.2)))))
|
|
|
|
|
(run-with-store store
|
|
|
|
|
;; Containers need a Bourne shell at /bin/sh.
|
|
|
|
|
(mlet* %store-monad ((bash (environment-bash container?
|
|
|
|
|
bootstrap?
|
|
|
|
|
system))
|
|
|
|
|
(prof-drv (manifest->derivation
|
|
|
|
|
manifest system bootstrap?))
|
|
|
|
|
(profile -> (derivation->output-path prof-drv))
|
|
|
|
|
(gc-root -> (assoc-ref opts 'gc-root)))
|
|
|
|
|
|
|
|
|
|
;; First build the inputs. This is necessary even for
|
|
|
|
|
;; --search-paths. Additionally, we might need to build bash for
|
|
|
|
|
;; a container.
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(build-environment (if (derivation? bash)
|
|
|
|
|
(list prof-drv bash)
|
|
|
|
|
(list prof-drv))
|
|
|
|
|
opts)
|
|
|
|
|
(mwhen gc-root
|
|
|
|
|
(register-gc-root profile gc-root))
|
|
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
((assoc-ref opts 'dry-run?)
|
|
|
|
|
(return #t))
|
|
|
|
|
((assoc-ref opts 'search-paths)
|
|
|
|
|
(show-search-paths profile manifest #:pure? pure?)
|
|
|
|
|
(return #t))
|
|
|
|
|
(container?
|
|
|
|
|
(let ((bash-binary
|
|
|
|
|
(if bootstrap?
|
|
|
|
|
bash
|
|
|
|
|
(string-append (derivation->output-path bash)
|
|
|
|
|
"/bin/sh"))))
|
|
|
|
|
(launch-environment/container #:command command
|
|
|
|
|
#:bash bash-binary
|
|
|
|
|
#:user user
|
|
|
|
|
#:user-mappings mappings
|
|
|
|
|
#:profile profile
|
|
|
|
|
#:manifest manifest
|
|
|
|
|
#:link-profile? link-prof?
|
|
|
|
|
#:network? network?)))
|
|
|
|
|
(else
|
|
|
|
|
(return
|
|
|
|
|
(exit/status
|
|
|
|
|
(launch-environment/fork command profile manifest
|
|
|
|
|
#:pure? pure?))))))))))))))
|