maint: The 'release' target builds a VM image.

* gnu/system/examples/vm-image.tmpl: New file.
* Makefile.am (GUIXSD_VM_SYSTEMS, GUIXSD_VM_IMAGE_BASE,
GUIXSD_VM_IMAGE_SIZE): New variables.
(release): Add logic to build a VM image.
(EXAMPLES): Add 'gnu/system/examples/vm-image.tmpl'.
* doc/guix.texi (Running GuixSD in a VM, Installing GuixSD in a VM): Mention the
pre-built VM image.
This commit is contained in:
Leo Famulari 2017-05-13 20:44:36 -04:00 committed by Ludovic Courtès
parent 56a03975eb
commit a6c642ef63
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
3 changed files with 97 additions and 12 deletions

View File

@ -5,6 +5,7 @@
# Copyright © 2016 Mathieu Lirzin <mthl@gnu.org> # Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
# Copyright © 2016, 2017 Mark H Weaver <mhw@netris.org> # Copyright © 2016, 2017 Mark H Weaver <mhw@netris.org>
# Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> # Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
# Copyright © 2017 Leo Famulari <leo@famulari.name>
# #
# This file is part of GNU Guix. # This file is part of GNU Guix.
# #
@ -224,7 +225,8 @@ AUX_FILES = \
EXAMPLES = \ EXAMPLES = \
gnu/system/examples/bare-bones.tmpl \ gnu/system/examples/bare-bones.tmpl \
gnu/system/examples/desktop.tmpl \ gnu/system/examples/desktop.tmpl \
gnu/system/examples/lightweight-desktop.tmpl gnu/system/examples/lightweight-desktop.tmpl \
gnu/system/examples/vm-image.tmpl
GOBJECTS = $(MODULES:%.scm=%.go) guix/config.go $(dist_noinst_DATA:%.scm=%.go) GOBJECTS = $(MODULES:%.scm=%.go) guix/config.go $(dist_noinst_DATA:%.scm=%.go)
@ -572,12 +574,21 @@ BINARY_TARBALLS = \
# Systems supported by GuixSD. # Systems supported by GuixSD.
GUIXSD_SUPPORTED_SYSTEMS ?= x86_64-linux i686-linux GUIXSD_SUPPORTED_SYSTEMS ?= x86_64-linux i686-linux
# Systems for which we build GuixSD VMs.
GUIXSD_VM_SYSTEMS ?= x86_64-linux
# Prefix of the GuixSD installation image file name. # Prefix of the GuixSD installation image file name.
GUIXSD_IMAGE_BASE = guixsd-usb-install-$(PACKAGE_VERSION) GUIXSD_IMAGE_BASE = guixsd-usb-install-$(PACKAGE_VERSION)
# Prefix of the GuixSD VM image file name.
GUIXSD_VM_IMAGE_BASE = guixsd-vm-image-$(PACKAGE_VERSION)
# Size of the installation image (for x86_64 typically). # Size of the installation image (for x86_64 typically).
GUIXSD_INSTALLATION_IMAGE_SIZE ?= 950MiB GUIXSD_INSTALLATION_IMAGE_SIZE ?= 950MiB
# Size of the VM image (for x86_64 typically).
GUIXSD_VM_IMAGE_SIZE ?= 2GiB
# The release process works in several phases: # The release process works in several phases:
# #
# 0. We assume the developer created a 'vX.Y' tag. # 0. We assume the developer created a 'vX.Y' tag.
@ -632,6 +643,20 @@ release: dist
mv "$(releasedir)/$(GUIXSD_IMAGE_BASE).$$system.xz.tmp" \ mv "$(releasedir)/$(GUIXSD_IMAGE_BASE).$$system.xz.tmp" \
"$(releasedir)/$(GUIXSD_IMAGE_BASE).$$system.xz" ; \ "$(releasedir)/$(GUIXSD_IMAGE_BASE).$$system.xz" ; \
done done
for system in $(GUIXSD_VM_SYSTEMS) ; do \
image=`$(top_builddir)/pre-inst-env \
guix system vm-image \
--system=$$system \
--image-size=$(GUIXSD_VM_IMAGE_SIZE) \
gnu/system/examples/vm-image.tmpl` ; \
if [ ! -f "$$image" ] ; then \
echo "failed to produced GuixSD VM image for $$system" >&2 ; \
exit 1 ; \
fi ; \
xz < "$$image" > "$(releasedir)/$(GUIXSD_VM_IMAGE_BASE).$$system.xz.tmp" ; \
mv "$(releasedir)/$(GUIXSD_VM_IMAGE_BASE).$$system.xz.tmp" \
"$(releasedir)/$(GUIXSD_VM_IMAGE_BASE).$$system.xz" ; \
done
@echo @echo
@echo "Congratulations! All the release files are now in $(releasedir)." @echo "Congratulations! All the release files are now in $(releasedir)."
@echo @echo

View File

@ -7634,8 +7634,11 @@ good.
@subsection Installing GuixSD in a Virtual Machine @subsection Installing GuixSD in a Virtual Machine
@cindex virtual machine, GuixSD installation @cindex virtual machine, GuixSD installation
If you'd like to install GuixSD in a virtual machine (VM) rather than on @cindex virtual private server (VPS)
your beloved machine, this section is for you. @cindex VPS (virtual private server)
If you'd like to install GuixSD in a virtual machine (VM) or on a
virtual private server (VPS) rather than on your beloved machine, this
section is for you.
To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a
disk image, follow these steps: disk image, follow these steps:
@ -15693,17 +15696,21 @@ example graph.
@subsection Running GuixSD in a Virtual Machine @subsection Running GuixSD in a Virtual Machine
@cindex virtual machine @cindex virtual machine
One way to run GuixSD in a virtual machine (VM) is to build a GuixSD To run GuixSD in a virtual machine (VM), one can either use the
virtual machine image using @command{guix system vm-image} pre-built GuixSD VM image distributed at
(@pxref{Invoking guix system}). The returned image is in qcow2 format, @indicateurl{ftp://alpha.gnu.org/guix/guixsd-vm-image-@value{VERSION}.@var{system}.tar.xz}
which the @uref{http://qemu.org/, QEMU emulator} can efficiently use. , or build their own virtual machine image using @command{guix system
vm-image} (@pxref{Invoking guix system}). The returned image is in
qcow2 format, which the @uref{http://qemu.org/, QEMU emulator} can
efficiently use.
@cindex QEMU @cindex QEMU
To run the image in QEMU, copy it out of the store (@pxref{The Store}) If you built your own image, you must copy it out of the store
and give yourself permission to write to the copy. When invoking QEMU, (@pxref{The Store}) and give yourself permission to write to the copy
you must choose a system emulator that is suitable for your hardware before you can use it. When invoking QEMU, you must choose a system
platform. Here is a minimal QEMU invocation that will boot the result emulator that is suitable for your hardware platform. Here is a minimal
of @command{guix system vm-image} on x86_64 hardware: QEMU invocation that will boot the result of @command{guix system
vm-image} on x86_64 hardware:
@example @example
$ qemu-system-x86_64 \ $ qemu-system-x86_64 \

View File

@ -0,0 +1,53 @@
;;; This is an operating system configuration template for a "bare-bones" setup,
;;; suitable for booting in a virtualized environment, including virtual private
;;; servers (VPS).
(use-modules (gnu))
(use-package-modules bootloaders disk nvi)
(define vm-image-motd (plain-file "motd" "
This is the GNU system. Welcome!
This instance of GuixSD is a bare-bones template for virtualized environments.
You will probably want to do these things first if you booted in a virtual
private server (VPS):
* Set a password for 'root'.
* Set up networking.
* Expand the root partition to fill the space available by 0) deleting and
recreating the partition with fdisk, 1) reloading the partition table with
partprobe, and then 2) resizing the filesystem with resize2fs.\n"))
(operating-system
(host-name "gnu")
(timezone "Etc/UTC")
(locale "en_US.utf8")
;; Assuming /dev/sdX is the target hard disk, and "my-root" is
;; the label of the target root file system.
(bootloader (grub-configuration (device "/dev/sda")
(terminal-outputs '(console))))
(file-systems (cons (file-system
(device "my-root")
(title 'label)
(mount-point "/")
(type "ext4"))
%base-file-systems))
;; This is where user accounts are specified. The "root"
;; account is implicit, and is initially created with the
;; empty password.
(users %base-user-accounts)
;; Globally-installed packages.
(packages (cons* nvi fdisk
grub ; mostly so xrefs to its manual work
parted ; partprobe
%base-packages))
(services (modify-services %base-services
(login-service-type config =>
(login-configuration
(inherit config)
(motd vm-image-motd))))))