# GNU Guix --- Functional package management for GNU # Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès # Copyright © 2017 Tobias Geerinckx-Rice # Copyright © 2018 Chris Marusich # # This file is part of GNU Guix. # # GNU Guix is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or (at # your option) any later version. # # GNU Guix is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Guix. If not, see . # # Test 'guix system', mostly error reporting. # set -e guix system --version tmpfile="t-guix-system-$$" errorfile="t-guix-system-error-$$" # Note: This directory is chosen outside $builddir so that relative file name # canonicalization doesn't mess up with 'current-source-directory', used by # 'local-file' ('load' forces 'relative' for # %FILE-PORT-NAME-CANONICALIZATION.) tmpdir="${TMPDIR:-/tmp}/t-guix-system-$$" mkdir "$tmpdir" trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT # Reporting of syntax errors. cat > "$tmpfile"< "$errorfile" then # This must not succeed. exit 1 else cat "$errorfile" grep "$tmpfile:2:3:.*missing.* initializers" "$errorfile" fi cat > "$tmpfile"< "$errorfile" then # This m;; -*- mode: scheme; -*- ;; This is an operating system configuration template ;; for a "desktop" setup with GNOME and Xfce where the ;; root partition is encrypted with LUKS, and a swap file. (use-modules (gnu) (gnu system nss) (guix utils)) (use-service-modules desktop sddm xorg) (use-package-modules gnome) (operating-system (host-name "antelope") (timezone "Europe/Paris") (locale "en_US.utf8") ;; Choose US English keyboard layout. The "altgr-intl" ;; variant provides dead keys for accented characters. (keyboard-layout (keyboard-layout "us" "altgr-intl")) ;; Use the UEFI variant of GRUB with the EFI System ;; Partition mounted on /boot/efi. (bootloader (bootloader-configuration (bootloader grub-efi-bootloader) (targets '("/boot/efi")) (keyboard-layout keyboard-layout))) ;; Specify a mapped device for the encrypted root partition. ;; The UUID is that returned by 'cryptsetup luksUUID'. (mapped-devices (list (mapped-device (source (uuid "12345678-1234-1234-1234-123456789abc")) (target "my-root") (type luks-device-mapping)))) (file-systems (append (list (file-system (device (file-system-label "my-root")) (mount-point "/") (type "ext4") (dependencies mapped-devices)) (file-system (device (uuid "1234-ABCD" 'fat)) (mount-point "/boot/efi") (type "vfat"))) %base-file-systems)) ;; Specify a swap file for the system, which resides on the ;; root file system. (swap-devices (list (swap-space (target "/swapfile")))) ;; Create user `bob' with `alice' as its initial password. (users (cons (user-account (name "bob") (comment "Alice's brother") (password (crypt "alice" "$6$abc")) (group "students") (supplementary-groups '("wheel" "netdev" "audio" "video"))) %base-user-accounts)) ;; Add the `students' group (groups (cons* (user-group (name "students")) %base-groups)) ;; This is where we specify system-wide packages. (packages (append (list ;; for user mounts gvfs) %base-packages)) ;; Add GNOME and Xfce---we can choose at the log-in screen ;; by clicking the gear. Use the "desktop" services, which ;; include the X11 log-in service, networking with ;; NetworkManager, and more. (services (if (target-x86-64?) (append (list (service gnome-desktop-service-type) (service xfce-desktop-service-type) (set-xorg-configuration (xorg-configuration (keyboard-layout keyboard-layout)))) %desktop-services) ;; FIXME: Since GDM depends on Rust (gdm -> gnome-shell -> gjs ;; -> mozjs -> rust) and Rust is currently unavailable on ;; non-x86_64 platforms, we use SDDM and Mate here instead of ;; GNOME and GDM. (append (list (service mate-desktop-service-type) (service xfce-desktop-service-type) (set-xorg-configuration (xorg-configuration (keyboard-layout keyboard-layout)) sddm-service-type)) %desktop-services))) ;; Allow resolution of '.local' host names with mDNS. (name-service-switch %mdns-host-lookup-nss)) ng inconsistent user accounts. make_user_config () { cat > "$tmpfile" <). drv1="`guix system vm "$tmpfile" -d`" drv2="`guix system vm "$tmpfile" -d`" test "$drv1" = "$drv2" drv1="`guix system image -t iso9660 "$tmpfile" -d`" drv2="`guix system image -t iso9660 "$tmpfile" -d`" test "$drv1" = "$drv2" # Check whether the graph commands work as expected. guix system extension-graph "$tmpfile" | grep 'label = "file-systems"' guix system shepherd-graph "$tmpfile" | grep 'label = "guix-daemon"' make_user_config "group-that-does-not-exist" "users" if guix system build "$tmpfile" -n 2> "$errorfile" then false else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi make_user_config "users" "group-that-does-not-exist" if guix system build "$tmpfile" -n 2> "$errorfile" then false else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi # Try 'local-file' and relative file name resolution. cat > "$tmpdir/config.scm"< "$tmpdir/my-torrc"< "$tmpdir/config.scm" <&1 | \ grep "config\.scm:4:2: warning:.*whatever.*relative to current directory" # Searching. guix system search tor | grep "^name: tor" guix system search tor | grep "^shepherdnames: tor" guix system search anonym network | grep "^name: tor" guix system search . > "$tmpdir/search" test $(wc -l < "$tmpdir/search") -gt 500 rm "$tmpdir/search" # Below, use -n (--dry-run) for the tests because if we actually tried to # build these images, the commands would take hours to run in the worst case. # Verify that the examples can be built. for example in gnu/system/examples/*.tmpl; do if echo "$example" | grep hurd; then target="--target=i586-pc-gnu" else target= fi guix system -n disk-image $target "$example" done # Verify that the images can be built. guix system -n vm gnu/system/examples/vm-image.tmpl guix system -n image gnu/system/images/pinebook-pro.scm guix system -n image -t qcow2 gnu/system/examples/vm-image.tmpl guix system -n image -t iso9660 gnu/system/examples/bare-bones.tmpl guix system -n docker-image gnu/system/examples/docker-image.tmpl # Verify that at least the raw image type is available. guix system --list-image-types | grep "raw"