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
parent 872a6fd988
commit 4b236c88ea
No known key found for this signature in database
GPG key ID: 2646FA30BACA7F08
3 changed files with 97 additions and 12 deletions

View file

@ -5,6 +5,7 @@
# Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
# Copyright © 2016, 2017 Mark H Weaver <mhw@netris.org>
# Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
# Copyright © 2017 Leo Famulari <leo@famulari.name>
#
# This file is part of GNU Guix.
#
@ -224,7 +225,8 @@ AUX_FILES = \
EXAMPLES = \
gnu/system/examples/bare-bones.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)
@ -571,12 +573,21 @@ BINARY_TARBALLS = \
# Systems supported by GuixSD.
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.
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).
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:
#
# 0. We assume the developer created a 'vX.Y' tag.
@ -631,6 +642,20 @@ release: dist
mv "$(releasedir)/$(GUIXSD_IMAGE_BASE).$$system.xz.tmp" \
"$(releasedir)/$(GUIXSD_IMAGE_BASE).$$system.xz" ; \
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 "Congratulations! All the release files are now in $(releasedir)."
@echo

View file

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