projects/guix·blob ruby-team · refs

139 lines · 5.3 KiB

1;; -*- mode: scheme; -*-
2;; This is an operating system configuration for a VM image.
3;; Modify it as you see fit and instantiate the changes by running:
4;;
5;; guix system reconfigure /etc/config.scm
6;;
7
8(use-modules (gnu)
9 (guix)
10 (srfi srfi-1)
11 (ice-9 match)
12 (guix channels)
13 (gnu packages package-management)
14 (gnu system image))
15(use-service-modules desktop mcron networking spice ssh xorg sddm)
16(use-package-modules bootloaders fonts
17 package-management xdisorg xorg)
18
19(define vm-image-motd (plain-file "motd" "
20\x1b[1;37mThis is the GNU system. Welcome!\x1b[0m
21
22This instance of Guix is a template for virtualized environments.
23You can reconfigure the whole system by adjusting /etc/config.scm
24and running:
25
26 guix system reconfigure /etc/config.scm
27
28Run '\x1b[1;37minfo guix\x1b[0m' to browse documentation.
29
30\x1b[1;33mConsider setting a password for the 'root' and 'guest' \
31accounts.\x1b[0m
32"))
33
34(operating-system
35 (host-name "gnu")
36 (timezone "Etc/UTC")
37 (locale "en_US.utf8")
38 (keyboard-layout (keyboard-layout "us" "altgr-intl"))
39
40 ;; Label for the GRUB boot menu.
41 (label (string-append "GNU Guix "
42 (or (getenv "GUIX_DISPLAYED_VERSION")
43 (package-version guix))))
44
45 (firmware '())
46
47 ;; Below we assume /dev/vda is the VM's hard disk.
48 ;; Adjust as needed.
49 (bootloader (bootloader-configuration
50 (bootloader grub-bootloader)
51 (targets '("/dev/vda"))
52 (terminal-outputs '(console))))
53 (file-systems (cons (file-system
54 (mount-point "/")
55 (device (file-system-label root-label))
56 (type "ext4"))
57 %base-file-systems))
58
59 (users (cons (user-account
60 (name "guest")
61 (comment "GNU Guix Live")
62 (password "") ;no password
63 (group "users")
64 (supplementary-groups '("wheel" "netdev"
65 "audio" "video")))
66 %base-user-accounts))
67
68 ;; Our /etc/sudoers file. Since 'guest' initially has an empty password,
69 ;; allow for password-less sudo.
70 (sudoers-file (plain-file "sudoers" "\
71root ALL=(ALL) ALL
72%wheel ALL=NOPASSWD: ALL\n"))
73
74 (pam-services
75 ;; Explicitly allow for empty passwords.
76 (base-pam-services #:allow-empty-passwords? #t))
77
78 (packages
79 (append (list font-bitstream-vera
80 ;; Auto-started script providing SPICE dynamic resizing for
81 ;; Xfce (see:
82 ;; https://gitlab.xfce.org/xfce/xfce4-settings/-/issues/142).
83 x-resize)
84 %base-packages))
85
86 (services
87 (append (list (service xfce-desktop-service-type)
88
89 ;; Choose SLiM, which is lighter than the default GDM.
90 (service slim-service-type
91 (slim-configuration
92 (auto-login? #t)
93 (default-user "guest")
94 (xorg-configuration
95 (xorg-configuration
96 ;; The QXL virtual GPU driver is added to provide
97 ;; a better SPICE experience.
98 (modules (cons xf86-video-qxl
99 %default-xorg-modules))
100 (keyboard-layout keyboard-layout)))))
101
102 ;; Uncomment the line below to add an SSH server.
103 ;;(service openssh-service-type)
104
105 ;; Add support for the SPICE protocol, which enables dynamic
106 ;; resizing of the guest screen resolution, clipboard
107 ;; integration with the host, etc.
108 (service spice-vdagent-service-type)
109
110 ;; Use the DHCP client service rather than NetworkManager.
111 (service dhcpcd-service-type))
112
113 ;; Remove some services that don't make sense in a VM.
114 (remove (lambda (service)
115 (let ((type (service-kind service)))
116 (or (memq type
117 (list gdm-service-type
118 sddm-service-type
119 wpa-supplicant-service-type
120 cups-pk-helper-service-type
121 network-manager-service-type
122 modem-manager-service-type))
123 (eq? 'network-manager-applet
124 (service-type-name type)))))
125 (modify-services %desktop-services
126 (login-service-type config =>
127 (login-configuration
128 (inherit config)
129 (motd vm-image-motd)))
130
131 ;; Install and run the current Guix rather than an older
132 ;; snapshot.
133 (guix-service-type config =>
134 (guix-configuration
135 (inherit config)
136 (guix (current-guix))))))))
137
138 ;; Allow resolution of '.local' host names with mDNS.
139 (name-service-switch %mdns-host-lookup-nss))