mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
Add 'guix system'.
* guix/scripts/system.scm: New file. * Makefile.am (MODULES): Add it. * po/POTFILES.in: Likewise. * doc/guix.texi (Using the Configuration System): Link to "Invoking guix system". (Invoking guix system): New node.
This commit is contained in:
parent
c0e57fb876
commit
523e48969b
4 changed files with 185 additions and 8 deletions
|
@ -77,6 +77,7 @@ MODULES = \
|
||||||
guix/scripts/substitute-binary.scm \
|
guix/scripts/substitute-binary.scm \
|
||||||
guix/scripts/authenticate.scm \
|
guix/scripts/authenticate.scm \
|
||||||
guix/scripts/refresh.scm \
|
guix/scripts/refresh.scm \
|
||||||
|
guix/scripts/system.scm \
|
||||||
guix.scm \
|
guix.scm \
|
||||||
$(GNU_SYSTEM_MODULES)
|
$(GNU_SYSTEM_MODULES)
|
||||||
|
|
||||||
|
|
|
@ -2548,6 +2548,7 @@ instance to support new system services.
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* Using the Configuration System:: Customizing your GNU system.
|
* Using the Configuration System:: Customizing your GNU system.
|
||||||
|
* Invoking guix system:: Instantiating a system configuration.
|
||||||
* Defining Services:: Adding new service definitions.
|
* Defining Services:: Adding new service definitions.
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
|
@ -2614,13 +2615,12 @@ daemon listening on port 2222, and allowing remote @code{root} logins
|
||||||
right command-line options, possibly with supporting configuration files
|
right command-line options, possibly with supporting configuration files
|
||||||
generated as needed (@pxref{Defining Services}).
|
generated as needed (@pxref{Defining Services}).
|
||||||
|
|
||||||
@c TODO: update when that command exists
|
|
||||||
Assuming the above snippet is stored in the @file{my-system-config.scm}
|
Assuming the above snippet is stored in the @file{my-system-config.scm}
|
||||||
file, the (yet unwritten!) @command{guix system --boot
|
file, the @command{guix system boot my-system-config.scm} command
|
||||||
my-system-config.scm} command instantiates that configuration, and makes
|
instantiates that configuration, and makes it the default GRUB boot
|
||||||
it the default GRUB boot entry. The normal way to change the system's
|
entry (@pxref{Invoking guix system}). The normal way to change the
|
||||||
configuration is by updating this file and re-running the @command{guix
|
system's configuration is by updating this file and re-running the
|
||||||
system} command.
|
@command{guix system} command.
|
||||||
|
|
||||||
At the Scheme level, the bulk of an @code{operating-system} declaration
|
At the Scheme level, the bulk of an @code{operating-system} declaration
|
||||||
is instantiated with the following monadic procedure (@pxref{The Store
|
is instantiated with the following monadic procedure (@pxref{The Store
|
||||||
|
@ -2635,6 +2635,33 @@ the packages, configuration files, and other supporting files needed to
|
||||||
instantiate @var{os}.
|
instantiate @var{os}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@node Invoking guix system
|
||||||
|
@subsection Invoking @code{guix system}
|
||||||
|
|
||||||
|
Once you have written an operating system declaration, as seen in the
|
||||||
|
previous section, it can be @dfn{instantiated} using the @command{guix
|
||||||
|
system} command. The synopsis is:
|
||||||
|
|
||||||
|
@example
|
||||||
|
guix system @var{options}@dots{} @var{action} @var{file}
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@var{file} must be the name of a file containing an
|
||||||
|
@code{operating-system} declaration. @var{action} specifies how the
|
||||||
|
operating system is instantiate. Currently only one value is supported:
|
||||||
|
|
||||||
|
@table @code
|
||||||
|
@item vm
|
||||||
|
@cindex virtual machine
|
||||||
|
Build a virtual machine that contain the operating system declared in
|
||||||
|
@var{file}, and return a script to run that virtual machine (VM).
|
||||||
|
|
||||||
|
The VM shares its store with the host system.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@var{options} can contain any of the common build options provided by
|
||||||
|
@command{guix build} (@pxref{Invoking guix build}).
|
||||||
|
|
||||||
|
|
||||||
@node Defining Services
|
@node Defining Services
|
||||||
@subsection Defining Services
|
@subsection Defining Services
|
||||||
|
|
148
guix/scripts/system.scm
Normal file
148
guix/scripts/system.scm
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
;;;
|
||||||
|
;;; 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 system)
|
||||||
|
#:use-module (guix ui)
|
||||||
|
#:use-module (guix store)
|
||||||
|
#:use-module (guix derivations)
|
||||||
|
#:use-module (guix packages)
|
||||||
|
#:use-module (guix utils)
|
||||||
|
#:use-module (guix monads)
|
||||||
|
#:use-module (guix scripts build)
|
||||||
|
#:use-module (gnu system vm)
|
||||||
|
#:use-module (srfi srfi-1)
|
||||||
|
#:use-module (srfi srfi-37)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
|
#:export (guix-system))
|
||||||
|
|
||||||
|
(define %user-module
|
||||||
|
;; Module in which the machine description file is loaded.
|
||||||
|
(let ((module (make-fresh-user-module)))
|
||||||
|
(for-each (lambda (iface)
|
||||||
|
(module-use! module (resolve-interface iface)))
|
||||||
|
'((gnu system)
|
||||||
|
(gnu system dmd)
|
||||||
|
(gnu system shadow)))
|
||||||
|
module))
|
||||||
|
|
||||||
|
(define (read-operating-system file)
|
||||||
|
"Read the operating-system declaration from FILE and return it."
|
||||||
|
;; TODO: Factorize.
|
||||||
|
(catch #t
|
||||||
|
(lambda ()
|
||||||
|
;; Avoid ABI incompatibility with the <operating-system> record.
|
||||||
|
(set! %fresh-auto-compile #t)
|
||||||
|
|
||||||
|
(save-module-excursion
|
||||||
|
(lambda ()
|
||||||
|
(set-current-module %user-module)
|
||||||
|
(primitive-load file))))
|
||||||
|
(lambda args
|
||||||
|
(match args
|
||||||
|
(('system-error . _)
|
||||||
|
(let ((err (system-error-errno args)))
|
||||||
|
(leave (_ "failed to open operating system file '~a': ~a~%")
|
||||||
|
file (strerror err))))
|
||||||
|
(_
|
||||||
|
(leave (_ "failed to load machine file '~a': ~s~%")
|
||||||
|
file args))))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Options.
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define (show-help)
|
||||||
|
(display (_ "Usage: guix system [OPTION] ACTION FILE
|
||||||
|
Build the operating system declared in FILE according to ACTION.\n"))
|
||||||
|
(display (_ "Currently the only valid value for ACTION is 'vm', which builds
|
||||||
|
a virtual machine of the given operating system.\n"))
|
||||||
|
(show-build-options-help)
|
||||||
|
(newline)
|
||||||
|
(display (_ "
|
||||||
|
-h, --help display this help and exit"))
|
||||||
|
(display (_ "
|
||||||
|
-V, --version display version information and exit"))
|
||||||
|
(newline)
|
||||||
|
(show-bug-report-information))
|
||||||
|
|
||||||
|
(define %options
|
||||||
|
;; Specifications 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 system")))
|
||||||
|
(option '(#\n "dry-run") #f #f
|
||||||
|
(lambda (opt name arg result)
|
||||||
|
(alist-cons 'dry-run? #t result)))
|
||||||
|
%standard-build-options))
|
||||||
|
|
||||||
|
(define %default-options
|
||||||
|
;; Alist of default option values.
|
||||||
|
`((system . ,(%current-system))
|
||||||
|
(substitutes? . #t)
|
||||||
|
(build-hook? . #t)
|
||||||
|
(max-silent-time . 3600)
|
||||||
|
(verbosity . 0)))
|
||||||
|
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Entry point.
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define (guix-system . args)
|
||||||
|
(define (parse-options)
|
||||||
|
;; Return the alist of option values.
|
||||||
|
(args-fold* args %options
|
||||||
|
(lambda (opt name arg result)
|
||||||
|
(leave (_ "~A: unrecognized option~%") name))
|
||||||
|
(lambda (arg result)
|
||||||
|
(if (assoc-ref result 'action)
|
||||||
|
(let ((previous (assoc-ref result 'argument)))
|
||||||
|
(if previous
|
||||||
|
(leave (_ "~a: extraneous argument~%") previous)
|
||||||
|
(alist-cons 'argument arg result)))
|
||||||
|
(let ((action (string->symbol arg)))
|
||||||
|
(case action
|
||||||
|
((vm) (alist-cons 'action action result))
|
||||||
|
(else (leave (_ "~a: unknown action~%")
|
||||||
|
action))))))
|
||||||
|
%default-options))
|
||||||
|
|
||||||
|
(with-error-handling
|
||||||
|
(let* ((opts (parse-options))
|
||||||
|
(file (assoc-ref opts 'argument))
|
||||||
|
(os (if file
|
||||||
|
(read-operating-system file)
|
||||||
|
(leave (_ "no configuration file specified~%"))))
|
||||||
|
(mdrv (system-qemu-image/shared-store-script os))
|
||||||
|
(store (open-connection))
|
||||||
|
(dry? (assoc-ref opts 'dry-run?))
|
||||||
|
(drv (run-with-store store mdrv)))
|
||||||
|
(set-build-options-from-command-line store opts)
|
||||||
|
(show-what-to-build store (list drv)
|
||||||
|
#:dry-run? dry?
|
||||||
|
#:use-substitutes? (assoc-ref opts 'substitutes?))
|
||||||
|
|
||||||
|
(unless dry?
|
||||||
|
(build-derivations store (list drv))
|
||||||
|
(display (derivation->output-path drv))
|
||||||
|
(newline)))))
|
|
@ -12,6 +12,7 @@ guix/scripts/hash.scm
|
||||||
guix/scripts/pull.scm
|
guix/scripts/pull.scm
|
||||||
guix/scripts/substitute-binary.scm
|
guix/scripts/substitute-binary.scm
|
||||||
guix/scripts/authenticate.scm
|
guix/scripts/authenticate.scm
|
||||||
|
guix/scripts/system.scm
|
||||||
guix/gnu-maintenance.scm
|
guix/gnu-maintenance.scm
|
||||||
guix/ui.scm
|
guix/ui.scm
|
||||||
guix/http-client.scm
|
guix/http-client.scm
|
||||||
|
|
Loading…
Reference in a new issue