From 538b99f31fb3eb41f90d6eb0e658e26e72123553 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 26 Apr 2019 11:39:53 +0200 Subject: system: Provide a new VM image configuration. * gnu/system/examples/vm-image.tmpl: Rewrite. * doc/guix.texi (Running Guix in a VM): Adjust accordingly. --- gnu/system/examples/vm-image.tmpl | 99 +++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 36 deletions(-) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index 6dc67b0901..d451c42bd8 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -1,58 +1,85 @@ -;;; This is an operating system configuration template for a "bare-bones" setup, -;;; suitable for booting in a virtualized environment, including virtual private -;;; servers (VPS). +;; This is an operating system configuration for a VM image. +;; Modify it as you see fit and instantiate the changes by running: +;; +;; guix system reconfigure /etc/config.scm +;; -(use-modules (gnu)) -(use-package-modules bootloaders disk nvi) +(use-modules (gnu) (srfi srfi-1)) +(use-service-modules xorg desktop) +(use-package-modules bootloaders nvi wget xorg) (define vm-image-motd (plain-file "motd" " -This is the GNU system. Welcome! +\x1b[1;37mThis is the GNU system. Welcome!\x1b[0m -This instance of Guix System is a bare-bones template for virtualized environments. +This instance of Guix is a template for virtualized environments. +You can reconfigure the whole system by adjusting /etc/config.scm +and running: -You will probably want to do these things first if you booted in a virtual -private server (VPS): + guix system reconfigure /etc/config.scm + +\x1b[1;33mConsider setting a password for the 'root' and 'guest' \ +accounts.\x1b[0m +")) + +(define this-file + (local-file "./vm-image.tmpl" "config.scm")) -* 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") + (keyboard-layout (keyboard-layout "us" "altgr-intl")) (firmware '()) - ;; Assuming /dev/sdX is the target hard disk, and "my-root" is - ;; the label of the target root file system. + ;; Below we assume /dev/vda is the VM's hard disk. + ;; Adjust as needed. (bootloader (bootloader-configuration (bootloader grub-bootloader) - (target "/dev/sda") + (target "/dev/vda") (terminal-outputs '(console)))) (file-systems (cons (file-system - (device (file-system-label "my-root")) (mount-point "/") + (device "/dev/vda1") (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 (append (list nvi fdisk - ;; mostly so xrefs to its manual work - grub - ;; partprobe - parted) - %base-packages)) - - (services (modify-services %base-services - (login-service-type config => - (login-configuration - (inherit config) - (motd vm-image-motd)))))) + (users (cons (user-account + (name "guest") + (comment "GNU Guix Live") + (password "") ;no password + (group "users") + (supplementary-groups '("wheel" "netdev" + "audio" "video"))) + %base-user-accounts)) + + (packages (append (list nvi wget) %base-packages)) + + (services + (append (list (service xfce-desktop-service-type) + + ;; Copy this file to /etc/config.scm in the OS. + (simple-service 'config-file etc-service-type + `(("config.scm" ,this-file))) + + ;; Choose SLiM, which is lighter than the default GDM. + (service slim-service-type + (slim-configuration + (auto-login? #t) + (default-user "guest") + (xorg-configuration + (xorg-configuration + (keyboard-layout keyboard-layout)))))) + + ;; Remove GDM. + (remove (lambda (service) + (eq? gdm-service-type (service-kind service))) + (modify-services %desktop-services + (login-service-type config => + (login-configuration + (inherit config) + (motd vm-image-motd))))))) + + ;; Allow resolution of '.local' host names with mDNS. + (name-service-switch %mdns-host-lookup-nss)) -- cgit v1.2.3 From 1ac6c33caec2c2a4aaadda49cb0febb5bfbf264c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 26 Apr 2019 16:47:11 +0200 Subject: vm-image: Use the actual file name of the current file. * gnu/system/examples/vm-image.tmpl (this-file): Use 'basename' and 'current-source-location'. --- gnu/system/examples/vm-image.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index d451c42bd8..62ed032731 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -22,7 +22,8 @@ accounts.\x1b[0m ")) (define this-file - (local-file "./vm-image.tmpl" "config.scm")) + (local-file (basename (assoc-ref (current-source-location) 'filename)) + "config.scm")) (operating-system -- cgit v1.2.3 From d7b05620a923757e0fee0888202f69cb96c348c8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 26 Apr 2019 18:24:55 +0200 Subject: vm-image: Remove NetworkManager & co. and add the DHCP client. * gnu/system/examples/vm-image.tmpl (services): Remove wpa-supplicant, cups-pk-helper, and NetworkManager. Add DHCP-CLIENT-SERVICE-TYPE. --- gnu/system/examples/vm-image.tmpl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index 62ed032731..b6f9daaf61 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -5,7 +5,7 @@ ;; (use-modules (gnu) (srfi srfi-1)) -(use-service-modules xorg desktop) +(use-service-modules desktop networking xorg) (use-package-modules bootloaders nvi wget xorg) (define vm-image-motd (plain-file "motd" " @@ -71,11 +71,19 @@ accounts.\x1b[0m (default-user "guest") (xorg-configuration (xorg-configuration - (keyboard-layout keyboard-layout)))))) + (keyboard-layout keyboard-layout))))) - ;; Remove GDM. + ;; Use the DHCP client service rather than NetworkManager. + (service dhcp-client-service-type)) + + ;; Remove GDM, NetworkManager, and wpa-supplicant, which don't make + ;; sense in a VM. (remove (lambda (service) - (eq? gdm-service-type (service-kind service))) + (let ((type (service-kind service))) + (memq type (list gdm-service-type + wpa-supplicant-service-type + cups-pk-helper-service-type + network-manager-service-type)))) (modify-services %desktop-services (login-service-type config => (login-configuration -- cgit v1.2.3 From ea2acfe98a3f3c00d15caa3e899ccbd126b97eb6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 27 Apr 2019 10:15:34 +0200 Subject: doc: Update bit about SSH in the VM. * doc/guix.texi (Running Guix in a VM): Remove mentions of 'lsh-server'; mention 'openssh-service-type' and add a cross-reference. * gnu/system/examples/vm-image.tmpl (services): Add a commented-out line for 'openssh-service-type'. --- doc/guix.texi | 9 ++++----- gnu/system/examples/vm-image.tmpl | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/doc/guix.texi b/doc/guix.texi index de30743d58..ddd20af256 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -24703,11 +24703,10 @@ network connectivity, for example @command{guix download}. @cindex SSH @cindex SSH server -To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)} -or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently -boot unsupervised. It requires you to type some characters to initialize the -randomness generator. In addition you need to forward the SSH port, 22 by -default, to the host. You can do this with +To enable SSH inside a VM you need to add an SSH server like +@code{openssh-service-type} to your VM (@pxref{Networking Services, +@code{openssh-service-type}}). In addition you need to forward the SSH port, +22 by default, to the host. You can do this with @example `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22 diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index b6f9daaf61..9bc08fa635 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -5,7 +5,7 @@ ;; (use-modules (gnu) (srfi srfi-1)) -(use-service-modules desktop networking xorg) +(use-service-modules desktop networking ssh xorg) (use-package-modules bootloaders nvi wget xorg) (define vm-image-motd (plain-file "motd" " @@ -73,6 +73,9 @@ accounts.\x1b[0m (xorg-configuration (keyboard-layout keyboard-layout))))) + ;; Uncomment the line below to add an SSH server. + ;;(service openssh-service-type) + ;; Use the DHCP client service rather than NetworkManager. (service dhcp-client-service-type)) -- cgit v1.2.3 From 5df29aad3bf77f6b9a4333ecae21c490485d8bf2 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 27 Apr 2019 14:57:36 +0200 Subject: vm-image: Add a font to the global profile. * gnu/system/examples/vm-image.tmpl (packages): Add FONT-BITSTREAM-VERA, for use by xfce-terminal, IceCat, etc. --- gnu/system/examples/vm-image.tmpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index 9bc08fa635..70a20d326c 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -6,7 +6,7 @@ (use-modules (gnu) (srfi srfi-1)) (use-service-modules desktop networking ssh xorg) -(use-package-modules bootloaders nvi wget xorg) +(use-package-modules bootloaders fonts nvi wget xorg) (define vm-image-motd (plain-file "motd" " \x1b[1;37mThis is the GNU system. Welcome!\x1b[0m @@ -55,7 +55,8 @@ accounts.\x1b[0m "audio" "video"))) %base-user-accounts)) - (packages (append (list nvi wget) %base-packages)) + (packages (append (list font-bitstream-vera nvi wget) + %base-packages)) (services (append (list (service xfce-desktop-service-type) -- cgit v1.2.3 From ff587e0fc0c7a7ba9366130acba8e349fa9a7e54 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 27 Apr 2019 14:58:27 +0200 Subject: vm-image: Mention 'info guix' in the MOTD. * gnu/system/examples/vm-image.tmpl (vm-image-motd): Mention 'info guix'. --- gnu/system/examples/vm-image.tmpl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index 70a20d326c..c8a5ee066b 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -17,6 +17,8 @@ and running: guix system reconfigure /etc/config.scm +Run '\x1b[1;37minfo guix\x1b[0m' to browse documentation. + \x1b[1;33mConsider setting a password for the 'root' and 'guest' \ accounts.\x1b[0m ")) -- cgit v1.2.3 From 6e0521eeede6bd06bc083073145413a04771aad3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 27 Apr 2019 15:07:31 +0200 Subject: vm-image: Allow for password-less sudo. * gnu/system/examples/vm-image.tmpl (sudoers-file): New field. --- gnu/system/examples/vm-image.tmpl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index c8a5ee066b..95cfcb6865 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -57,6 +57,12 @@ accounts.\x1b[0m "audio" "video"))) %base-user-accounts)) + ;; Our /etc/sudoers file. Since 'guest' initially has an empty password, + ;; allow for password-less sudo. + (sudoers-file (plain-file "sudoers" "\ +root ALL=(ALL) ALL +%wheel ALL=NOPASSWD: ALL\n")) + (packages (append (list font-bitstream-vera nvi wget) %base-packages)) -- cgit v1.2.3 From a4ae05fb8bdac6617e75c97ee0fe7fe1c6992de6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 28 Apr 2019 15:12:50 +0200 Subject: vm-image: Add 'nss-certs' to the global package set. * gnu/system/examples/vm-image.tmpl (packages): Add NSS-CERTS. --- gnu/system/examples/vm-image.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu/system/examples/vm-image.tmpl') diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl index 95cfcb6865..a140082c0b 100644 --- a/gnu/system/examples/vm-image.tmpl +++ b/gnu/system/examples/vm-image.tmpl @@ -6,7 +6,7 @@ (use-modules (gnu) (srfi srfi-1)) (use-service-modules desktop networking ssh xorg) -(use-package-modules bootloaders fonts nvi wget xorg) +(use-package-modules bootloaders certs fonts nvi wget xorg) (define vm-image-motd (plain-file "motd" " \x1b[1;37mThis is the GNU system. Welcome!\x1b[0m @@ -63,7 +63,7 @@ accounts.\x1b[0m root ALL=(ALL) ALL %wheel ALL=NOPASSWD: ALL\n")) - (packages (append (list font-bitstream-vera nvi wget) + (packages (append (list font-bitstream-vera nss-certs nvi wget) %base-packages)) (services -- cgit v1.2.3