;; eval ""$(sed 's,-nic user[^ ]* ,,' "$(make check-system)" | tail -1 | sed 's/\sexec\s//')" -m 4096  -smp 2 -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22"
;; ssh -fL 5901:localhost:5901 -F /dev/null localhost -p 10022

(use-modules (gnu)
             (guix)
             (guix build utils)
             (ice-9 match)
             (srfi srfi-1)

             (services jenkins)
             (config))
(use-service-modules desktop networking ssh xorg shepherd)
(use-package-modules bootloaders certs fonts nvi
                     package-management wget xorg
                     linux lisp lisp-xyz pulseaudio astronomy ratpoison)

(define vm-image-motd (plain-file "motd" "
\x1b[1;37mThis is the GNU system.  Welcome!\x1b[0m

This instance of Guix is a template for virtualized environments.
You can reconfigure the whole system by adjusting /etc/config.scm
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 'oleg' \
accounts.\x1b[0m
"))

(operating-system
  (host-name "gnu")
  (timezone "Etc/UTC")
  (locale "en_US.utf8")
  (keyboard-layout (keyboard-layout "us" "altgr-intl"))

  ;; Label for the GRUB boot menu.
  (label (string-append "GNU Guix " (package-version guix)))

  (firmware '())

  ;; Below we assume /dev/vda is the VM's hard disk.
  ;; Adjust as needed.
  (bootloader (bootloader-configuration
               (bootloader grub-bootloader)
               (target "/dev/vda")
               (terminal-outputs '(console))))
  (file-systems (cons (file-system
                        (mount-point "/")
                        (device "/dev/vda1")
                        (type "ext4"))
                      %base-file-systems))

  (users (cons (user-account
                (name "oleg")
                (comment "GNU Guix Live")
                (password (crypt "oleg" "$6$abc"))
                (group "users")
                (uid 1000)
                (supplementary-groups '("wheel" "netdev"
                                        "audio" "video")))
               %base-user-accounts))

  ;; Our /etc/sudoers file.  Since 'oleg' 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 strace)
                    %base-packages))

  (services
   (append (list (service openssh-service-type
                          (openssh-configuration
                           (authorized-keys
                            `(("oleg" ,(local-file "/home/oleg/.ssh/id_rsa.pub"))))))

                 ;; Use the DHCP client service rather than NetworkManager.
                 (service dhcp-client-service-type))

           %base-services))

  ;; Allow resolution of '.local' host names with mDNS.
  (name-service-switch %mdns-host-lookup-nss))
