2022-12-15 18:39:35 +00:00
|
|
|
;; -*- mode: scheme; -*-
|
2019-04-26 09:39:53 +00:00
|
|
|
;; 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
|
|
|
|
;;
|
2017-05-14 00:44:36 +00:00
|
|
|
|
2019-04-30 21:12:03 +00:00
|
|
|
(use-modules (gnu) (guix) (srfi srfi-1))
|
2022-01-07 02:43:47 +00:00
|
|
|
(use-service-modules desktop mcron networking spice ssh xorg sddm)
|
2019-04-30 21:12:03 +00:00
|
|
|
(use-package-modules bootloaders certs fonts nvi
|
|
|
|
package-management wget xorg)
|
2017-05-14 00:44:36 +00:00
|
|
|
|
|
|
|
(define vm-image-motd (plain-file "motd" "
|
2019-04-26 09:39:53 +00:00
|
|
|
\x1b[1;37mThis is the GNU system. Welcome!\x1b[0m
|
2017-05-14 00:44:36 +00:00
|
|
|
|
2019-04-26 09:39:53 +00:00
|
|
|
This instance of Guix is a template for virtualized environments.
|
|
|
|
You can reconfigure the whole system by adjusting /etc/config.scm
|
|
|
|
and running:
|
2017-05-14 00:44:36 +00:00
|
|
|
|
2019-04-26 09:39:53 +00:00
|
|
|
guix system reconfigure /etc/config.scm
|
|
|
|
|
2019-04-27 12:58:27 +00:00
|
|
|
Run '\x1b[1;37minfo guix\x1b[0m' to browse documentation.
|
|
|
|
|
2019-04-26 09:39:53 +00:00
|
|
|
\x1b[1;33mConsider setting a password for the 'root' and 'guest' \
|
|
|
|
accounts.\x1b[0m
|
|
|
|
"))
|
|
|
|
|
2021-05-10 03:40:34 +00:00
|
|
|
;;; XXX: Xfce does not implement what is needed for the SPICE dynamic
|
|
|
|
;;; resolution to work (see:
|
|
|
|
;;; https://gitlab.xfce.org/xfce/xfce4-settings/-/issues/142). Workaround it
|
|
|
|
;;; by manually invoking xrandr every second.
|
|
|
|
(define auto-update-resolution-crutch
|
|
|
|
#~(job '(next-second)
|
|
|
|
(lambda ()
|
|
|
|
(setenv "DISPLAY" ":0.0")
|
|
|
|
(setenv "XAUTHORITY" "/home/guest/.Xauthority")
|
|
|
|
(execl (string-append #$xrandr "/bin/xrandr") "xrandr" "-s" "0"))
|
|
|
|
#:user "guest"))
|
|
|
|
|
2017-05-14 00:44:36 +00:00
|
|
|
(operating-system
|
|
|
|
(host-name "gnu")
|
|
|
|
(timezone "Etc/UTC")
|
|
|
|
(locale "en_US.utf8")
|
2019-04-26 09:39:53 +00:00
|
|
|
(keyboard-layout (keyboard-layout "us" "altgr-intl"))
|
2017-05-14 00:44:36 +00:00
|
|
|
|
2019-04-30 21:12:03 +00:00
|
|
|
;; Label for the GRUB boot menu.
|
2022-08-09 09:48:52 +00:00
|
|
|
(label (string-append "GNU Guix "
|
|
|
|
(or (getenv "GUIX_DISPLAYED_VERSION")
|
|
|
|
(package-version guix))))
|
2019-04-30 21:12:03 +00:00
|
|
|
|
2019-01-21 18:37:59 +00:00
|
|
|
(firmware '())
|
2018-12-11 14:42:56 +00:00
|
|
|
|
2019-04-26 09:39:53 +00:00
|
|
|
;; Below we assume /dev/vda is the VM's hard disk.
|
|
|
|
;; Adjust as needed.
|
2017-09-02 23:19:38 +00:00
|
|
|
(bootloader (bootloader-configuration
|
|
|
|
(bootloader grub-bootloader)
|
2021-08-07 19:07:47 +00:00
|
|
|
(targets '("/dev/vda"))
|
2017-09-02 23:19:38 +00:00
|
|
|
(terminal-outputs '(console))))
|
2017-05-14 00:44:36 +00:00
|
|
|
(file-systems (cons (file-system
|
|
|
|
(mount-point "/")
|
2019-04-26 09:39:53 +00:00
|
|
|
(device "/dev/vda1")
|
2017-05-14 00:44:36 +00:00
|
|
|
(type "ext4"))
|
|
|
|
%base-file-systems))
|
|
|
|
|
2019-04-26 09:39:53 +00:00
|
|
|
(users (cons (user-account
|
|
|
|
(name "guest")
|
|
|
|
(comment "GNU Guix Live")
|
|
|
|
(password "") ;no password
|
|
|
|
(group "users")
|
|
|
|
(supplementary-groups '("wheel" "netdev"
|
|
|
|
"audio" "video")))
|
|
|
|
%base-user-accounts))
|
|
|
|
|
2019-04-27 13:07:31 +00:00
|
|
|
;; 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"))
|
|
|
|
|
2019-04-28 13:12:50 +00:00
|
|
|
(packages (append (list font-bitstream-vera nss-certs nvi wget)
|
2019-04-27 12:57:36 +00:00
|
|
|
%base-packages))
|
2019-04-26 09:39:53 +00:00
|
|
|
|
|
|
|
(services
|
|
|
|
(append (list (service xfce-desktop-service-type)
|
|
|
|
|
|
|
|
;; 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
|
2021-05-05 16:07:39 +00:00
|
|
|
;; The QXL virtual GPU driver is added to provide
|
|
|
|
;; a better SPICE experience.
|
|
|
|
(modules (cons xf86-video-qxl
|
|
|
|
%default-xorg-modules))
|
2019-04-26 16:24:55 +00:00
|
|
|
(keyboard-layout keyboard-layout)))))
|
2019-04-26 09:39:53 +00:00
|
|
|
|
2019-04-27 08:15:34 +00:00
|
|
|
;; Uncomment the line below to add an SSH server.
|
|
|
|
;;(service openssh-service-type)
|
|
|
|
|
2021-05-05 16:07:39 +00:00
|
|
|
;; Add support for the SPICE protocol, which enables dynamic
|
|
|
|
;; resizing of the guest screen resolution, clipboard
|
|
|
|
;; integration with the host, etc.
|
|
|
|
(service spice-vdagent-service-type)
|
|
|
|
|
2021-05-10 03:40:34 +00:00
|
|
|
(simple-service 'cron-jobs mcron-service-type
|
|
|
|
(list auto-update-resolution-crutch))
|
|
|
|
|
2019-04-26 16:24:55 +00:00
|
|
|
;; Use the DHCP client service rather than NetworkManager.
|
|
|
|
(service dhcp-client-service-type))
|
|
|
|
|
2022-01-07 02:43:47 +00:00
|
|
|
;; Remove some services that don't make sense in a VM.
|
2019-04-26 09:39:53 +00:00
|
|
|
(remove (lambda (service)
|
2019-04-26 16:24:55 +00:00
|
|
|
(let ((type (service-kind service)))
|
2019-05-16 12:37:23 +00:00
|
|
|
(or (memq type
|
|
|
|
(list gdm-service-type
|
2022-01-07 02:43:47 +00:00
|
|
|
sddm-service-type
|
2019-05-16 12:37:23 +00:00
|
|
|
wpa-supplicant-service-type
|
|
|
|
cups-pk-helper-service-type
|
2019-05-16 12:42:40 +00:00
|
|
|
network-manager-service-type
|
|
|
|
modem-manager-service-type))
|
2019-05-16 12:37:23 +00:00
|
|
|
(eq? 'network-manager-applet
|
|
|
|
(service-type-name type)))))
|
2019-04-26 09:39:53 +00:00
|
|
|
(modify-services %desktop-services
|
|
|
|
(login-service-type config =>
|
|
|
|
(login-configuration
|
|
|
|
(inherit config)
|
2022-08-09 08:46:07 +00:00
|
|
|
(motd vm-image-motd)))
|
|
|
|
|
|
|
|
;; Install and run the current Guix rather than an older
|
|
|
|
;; snapshot.
|
|
|
|
(guix-service-type config =>
|
|
|
|
(guix-configuration
|
|
|
|
(inherit config)
|
|
|
|
(guix (current-guix))))))))
|
2019-04-26 09:39:53 +00:00
|
|
|
|
|
|
|
;; Allow resolution of '.local' host names with mDNS.
|
|
|
|
(name-service-switch %mdns-host-lookup-nss))
|