From a6c642ef63012508f755a1329aa66e4b09da72b5 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Sat, 13 May 2017 20:44:36 -0400 Subject: [PATCH] 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. --- Makefile.am | 27 +++++++++++++++- doc/guix.texi | 29 ++++++++++------- gnu/system/examples/vm-image.tmpl | 53 +++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 12 deletions(-) create mode 100644 gnu/system/examples/vm-image.tmpl diff --git a/Makefile.am b/Makefile.am index b90f419b14..c2fc2642a7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,7 @@ # Copyright © 2016 Mathieu Lirzin # Copyright © 2016, 2017 Mark H Weaver # Copyright © 2017 Mathieu Othacehe +# Copyright © 2017 Leo Famulari # # 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) @@ -572,12 +574,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. @@ -632,6 +643,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 diff --git a/doc/guix.texi b/doc/guix.texi index 7baf6ee38a..3523937030 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7634,8 +7634,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: @@ -15693,17 +15696,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 \ diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl new file mode 100644 index 0000000000..57ac71c535 --- /dev/null +++ b/gnu/system/examples/vm-image.tmpl @@ -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))))))