2.3'/>
<meta name='robots' content='noindex, nofollow'/>
<link rel='stylesheet' type='text/css' href='/cgit-static/cgit.css'/>
<link rel='stylesheet' type='text/css' href='/cgit-static/better-cgit-markdown-heading-color.css'/>
<link rel='shortcut icon' href='/cgit-static/favicon.ico'/>
<link rel='alternate' title='Atom feed' href='https://git.koszko.org/guix/atom/?h=koszko' type='application/atom+xml'/>
</head>
<body>
<div id='cgit'><table id='header'>
<tr>
<td class='logo' rowspan='2'><a href='/'><img src='https://git.koszko.org/cgit-static/cgit.png' alt='cgit logo'/></a></td>
<td class='main'><a href='/'>index</a> : <a href='/guix/'>guix</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='bf33a77ea784cd21e7b1a283c98c2fa76dec1f43'/><select name='h' onchange='this.form.submit();'>
<option value='koszko' selected='selected'>koszko</option>
<option value='koszko-scripts'>koszko-scripts</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>Wojtek's customized Guix</td><td class='sub right'></td></tr></table>
<table class='tabs'><tr><td>
<a class='active' href='/guix/about/'>about</a><a href='/guix/'>summary</a><a href='/guix/refs/?id=bf33a77ea784cd21e7b1a283c98c2fa76dec1f43'>refs</a><a href='/guix/log/'>log</a><a href='/guix/tree/?id=bf33a77ea784cd21e7b1a283c98c2fa76dec1f43'>tree</a><a href='/guix/commit/?id=bf33a77ea784cd21e7b1a283c98c2fa76dec1f43'>commit</a><a href='/guix/diff/?id=bf33a77ea784cd21e7b1a283c98c2fa76dec1f43'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/'>
<input type='hidden' name='id' value='bf33a77ea784cd21e7b1a283c98c2fa76dec1f43'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='content'><div id='summary'><pre>
# GNU Guix --- Functional package management for GNU
# Copyright © 2014-2022, 2024 Ludovic Courtès &lt;ludo@gnu.org&gt;
# Copyright © 2017 Tobias Geerinckx-Rice &lt;me@tobias.gr&gt;
# Copyright © 2018 Chris Marusich &lt;cmmarusich@gmail.com&gt;
#
# 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 &lt;http://www.gnu.org/licenses/&gt;.

#
# Test &apos;guix system&apos;, mostly error reporting.
#

set -e

guix system --version

tmpfile=&quot;t-guix-system-$$&quot;
errorfile=&quot;t-guix-system-error-$$&quot;

# Note: This directory is chosen outside $builddir so that relative file name
# canonicalization doesn&apos;t mess up with &apos;current-source-directory&apos;, used by
# &apos;local-file&apos; (&apos;load&apos; forces &apos;relative&apos; for
# %FILE-PORT-NAME-CANONICALIZATION.)
tmpdir=&quot;${TMPDIR:-/tmp}/t-guix-system-$$&quot;
mkdir &quot;$tmpdir&quot;

trap &apos;rm -f &quot;$tmpfile&quot; &quot;$errorfile&quot; &quot;$tmpdir&quot;/*; rmdir &quot;$tmpdir&quot;&apos; EXIT

# Reporting of syntax errors.

cat &gt; &quot;$tmpfile&quot;&lt;&lt;EOF
;; This is line 1, and the next one is line 2.
   (operating-system)
;; The &apos;T&apos; is at column 3.
EOF

if guix system vm &quot;$tmpfile&quot; 2&gt; &quot;$errorfile&quot;
then
    # This must not succeed.
    exit 1
else
    cat &quot;$errorfile&quot;
    grep &quot;$tmpfile:2:3:.*missing.* initializers&quot; &quot;$errorfile&quot;
fi


cat &gt; &quot;$tmpfile&quot;&lt;&lt;EOF
;; This is line 1, and the next one is line 2.
   (operating-system
;; This is line 3, and there is no closing paren!
EOF

if guix system vm &quot;$tmpfile&quot; 2&gt; &quot;$errorfile&quot;
then
    # This must not succeed.
    exit 1
else
    cat &quot;$errorfile&quot;

    # Guile 3.0.6 gets line/column numbers for &apos;read-error&apos; wrong
    # (zero-indexed): &lt;https://bugs.gnu.org/48089&gt;.
    grep &quot;$tmpfile:4:1: missing closing paren&quot; &quot;$errorfile&quot; || \
    grep &quot;$tmpfile:3:0: missing closing paren&quot; &quot;$errorfile&quot;
fi


# Reporting of module not found errors.

cat &gt; &quot;$tmpfile&quot; &lt;&lt;EOF
;; Line 1.
(use-modules (gnu))
  (use-service-modules openssh)
EOF

if guix system build &quot;$tmpfile&quot; -n 2&gt; &quot;$errorfile&quot;
then false
else
    grep &quot;$tmpfile:3:2: .*module .*openssh.*not found&quot; &quot;$errorfile&quot;
    grep &quot;Try.*use-service-modules ssh&quot; &quot;$errorfile&quot;
fi

cat &gt; &quot;$tmpfile&quot; &lt;&lt;EOF
;; Line 1.
(use-modules (gnu))
  (use-package-modules qemu)
EOF

if guix system build &quot;$tmpfile&quot; -n 2&gt; &quot;$errorfile&quot;
then false
else
    grep &quot;$tmpfile:3:2: .*module .*qemu.*not found&quot; &quot;$errorfile&quot;
    grep &quot;Try.*use-package-modules virtualization&quot; &quot;$errorfile&quot;
fi

# Reporting of unbound variables.

cat &gt; &quot;$tmpfile&quot; &lt;&lt;EOF
(use-modules (gnu))                                   ; 1
(use-service-modules networking)                      ; 2

(operating-system                                     ; 4
  (host-name &quot;antelope&quot;)                              ; 5
  (timezone &quot;Europe/Paris&quot;)                           ; 6
  (locale &quot;en_US.UTF-8&quot;)                              ; 7

  (bootloader (GRUB-config (targets (list &quot;/dev/sdX&quot;))))        ; 9
  (file-systems (cons (file-system
                        (device (file-system-label &quot;root&quot;))
                        (mount-point &quot;/&quot;)
                        (type &quot;ext4&quot;))
                      %base-file-systems)))
EOF

if guix system build &quot;$tmpfile&quot; -n 2&gt; &quot;$errorfile&quot;
then false
else
    if test &quot;`guile -c &apos;(display (effective-version))&apos;`&quot; = 3.0
    then
	# FIXME: With Guile 3.3.0 the error is reported on line 11.
	# See &lt;https://bugs.gnu.org/38388&gt;.
	grep &quot;$tmpfile:[0-9]\+:[0-9]\+:.*GRUB-config.*[Uu]nbound variable&quot; &quot;$errorfile&quot;
    elif test &quot;`guile -c &apos;(display (effective-version))&apos;`&quot; = 2.2
    then
	# FIXME: With Guile 2.2.0 the error is reported on line 4.
	# See &lt;http://bugs.gnu.org/26107&gt;.
	grep &quot;$tmpfile:[49]:[0-9]\+:.*GRUB-config.*[Uu]nbound variable&quot; &quot;$errorfile&quot;
    else
	grep &quot;$tmpfile:9:[0-9]\+:.*GRUB-config.*[Uu]nbound variable&quot; &quot;$errorfile&quot;
    fi
fi

cat &gt; &quot;$tmpfile&quot; &lt;&lt;EOF
(use-modules (gnu))                                    ; 1

(operating-system                                      ; 3
  (file-systems (cons (file-system                     ; 4
                        (device (file-system-label &quot;root&quot;))
                        (mount-point &quot;/&quot;)              ; 6
                        (type &quot;ext4&quot;))))               ; 7 (!!)
                      %base-file-systems)
EOF

if guix system build &quot;$tmpfile&quot; -n 2&gt; &quot;$errorfile&quot;
then false
else
    # Here &apos;%base-file-systems&apos; appears as if it were a field specified of the
    # enclosing &apos;operating-system&apos; form due to parenthesis mismatch.
    grep &quot;$tmpfile:3:[0-9]\+:.*%base-file-system.*invalid field specifier&quot; \
	 &quot;$errorfile&quot;
fi

OS_BASE=&apos;
  (host-name &quot;antelope&quot;)
  (timezone &quot;Europe/Paris&quot;)
  (locale &quot;en_US.UTF-8&quot;)

  (bootloader (bootloader-configuration
               (bootloader grub-bootloader)
               (targets (list &quot;/dev/sdX&quot;))))
  (file-systems (cons (file-system
                        (device (file-system-label &quot;root&quot;))
                        (mount-point &quot;/&quot;)
                        (type &quot;ext4&quot;))
                      %base-file-systems))
&apos;

# Reporting of duplicate service identifiers.

cat &gt; &quot;$tmpfile&quot; &lt;&lt;EOF
(use-modules (gnu))
(use-service-modules networking)

(operating-system
  $OS_BASE
  (services (cons* (service dhcp-client-service-type)
                   (service dhcp-client-service-type) ;twice!
                   %base-services)))
EOF

if guix system vm &quot;$tmpfile&quot; 2&gt; &quot;$errorfile&quot;
then
    # This must not succeed.
    exit 1
else
    grep &quot;service &apos;networking&apos;.*more than once&quot; &quot;$errorfile&quot;
fi

# Reporting unmet shepherd requirements.

cat &gt; &quot;$tmpfile&quot; &lt;&lt;EOF
(use-modules (gnu) (gnu services shepherd))
(use-service-modules networking)

(define buggy-service-type
  (shepherd-service-type
    &apos;buggy
    (lambda _
      (shepherd-service
        (provision &apos;(buggy!))
        (requirement &apos;(does-not-exist))
        (start #t)))
    (description &quot;Buggy.&quot;)))

(operating-system
  $OS_BASE
  (services (cons (service buggy-service-type #t)
                  %base-services)))
EOF

if guix system build &quot;$tmpfile&quot; 2&gt; &quot;$errorfile&quot;
then
    exit 1
else
    grep &quot;service &apos;buggy!&apos;.*&apos;does-not-exist&apos;.*not provided&quot; &quot;$errorfile&quot;
fi

# Reporting inconsistent user accounts.

make_user_config ()
{
    cat &gt; &quot;$tmpfile&quot; &lt;&lt;EOF
(use-modules (gnu))
(use-service-modules networking)

(operating-system
  (host-name &quot;antelope&quot;)
  (timezone &quot;Europe/Paris&quot;)
  (locale &quot;en_US.UTF-8&quot;)

  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (targets (list &quot;/dev/sdX&quot;))))
  (file-systems (cons (file-system
                        (device (file-system-label &quot;root&quot;))
                        (mount-point &quot;/&quot;)
                        (type &quot;ext4&quot;))
                      %base-file-systems))
  (users (list (user-account
                 (name &quot;dave&quot;)
                 (home-directory &quot;/home/dave&quot;)
                 (group &quot;$1&quot;)
                 (supplementary-groups &apos;(&quot;$2&quot;))))))
EOF
}

make_user_config &quot;users&quot; &quot;wheel&quot;
guix system build &quot;$tmpfile&quot; -n       # succeeds

guix system build &quot;$tmpfile&quot; -d	      # succeeds
guix system build &quot;$tmpfile&quot; -d | grep &apos;\.drv$&apos;

guix system vm &quot;$tmpfile&quot; -d	      # succeeds
guix system vm &quot;$tmpfile&quot; -d | grep &apos;\.drv$&apos;

# Make sure the behavior is deterministic (&lt;https://bugs.gnu.org/32652&gt;).
drv1=&quot;`guix system vm &quot;$tmpfile&quot; -d`&quot;
drv2=&quot;`guix system vm &quot;$tmpfile&quot; -d`&quot;
test &quot;$drv1&quot; = &quot;$drv2&quot;
drv1=&quot;`guix system image -t iso9660 &quot;$tmpfile&quot; -d`&quot;
drv2=&quot;`guix system image -t iso9660 &quot;$tmpfile&quot; -d`&quot;
test &quot;$drv1&quot; = &quot;$drv2&quot;

# Check whether the graph commands work as expected.
guix system extension-graph &quot;$tmpfile&quot; | grep &apos;label = &quot;file-systems&quot;&apos;
guix system shepherd-graph &quot;$tmpfile&quot; | grep &apos;label = &quot;guix-daemon&quot;&apos;

make_user_config &quot;group-that-does-not-exist&quot; &quot;users&quot;
if guix system build &quot;$tmpfile&quot; -n 2&gt; &quot;$errorfile&quot;
then false
else grep &quot;primary group.*group-that-does-not-exist.*undeclared&quot; &quot;$errorfile&quot;; fi

make_user_config &quot;users&quot; &quot;group-that-does-not-exist&quot;
if guix system build &quot;$tmpfile&quot; -n 2&gt; &quot;$errorfile&quot;
then false
else grep &quot;supplementary group.*group-that-does-not-exist.*undeclared&quot; &quot;$errorfile&quot;; fi

# Try &apos;local-file&apos; and relative file name resolution.

cat &gt; &quot;$tmpdir/config.scm&quot;&lt;&lt;EOF
(use-modules (gnu))
(use-service-modules networking)

(operating-system
  $OS_BASE
  (services (cons (service tor-service-type
                           (tor-configuration
                             (config-file (local-file &quot;my-torrc&quot;))))
                  %base-services)))
EOF

cat &gt; &quot;$tmpdir/my-torrc&quot;&lt;&lt;EOF
# This is an example file.
EOF

# In both cases &apos;my-torrc&apos; should be properly resolved.
guix system build &quot;$tmpdir/config.scm&quot; -n
(cd &quot;$tmpdir&quot;; guix system build &quot;config.scm&quot; -n)

# Check that we get a warning when passing &apos;local-file&apos; a non-literal relative
# file name.
cat &gt; &quot;$tmpdir/config.scm&quot; &lt;&lt;EOF
(use-modules (guix))

(define (bad-local-file file)
  (local-file file))

(bad-local-file &quot;whatever.scm&quot;)
EOF
guix system build &quot;$tmpdir/config.scm&quot; -n &amp;&amp; false
guix system build &quot;$tmpdir/config.scm&quot; -n 2&gt;&amp;1 | \
    grep &quot;config\.scm:4:2: warning:.*whatever.*relative to current directory&quot;

# Searching.
guix system search tor | grep &quot;^name: tor&quot;
guix system search tor | grep &quot;^shepherdnames: tor&quot;
guix system search anonym network | grep &quot;^name: tor&quot;
guix system search . &gt; &quot;$tmpdir/search&quot;
test $(wc -l &lt; &quot;$tmpdir/search&quot;) -gt 500
rm &quot;$tmpdir/search&quot;

# 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
    case &quot;$example&quot; in
	*hurd*)
            options=&quot;--target=i586-pc-gnu&quot;;;
	*asus*)
	    # &apos;asus-c201.tmpl&apos; uses &apos;linux-libre-arm-generic&apos;, which is an
	    # ARM-only package.
            options=&quot;--system=armhf-linux&quot;;;
        *raspberry*)
	    # The Raspberry Pi templates &apos;linux-libre-arm64-generic&apos;, which is
	    # an ARM-only package.
            options=&quot;--system=aarch64-linux&quot;;;
        *plasma*)
            # Some architectures do not support all the packages Plasma
            # depends on so restrict to x86_64-linux.
            options=&quot;--system=x86_64-linux&quot;;;
	*vm-image*)
	    # The VM image tries to build &apos;current-guix&apos; as per &apos;guix pull&apos;.
	    # Skip it.
	    continue
	    ;;
	*desktop*)
	    # This image uses &apos;grub-efi-bootloader&apos; so it needs a GPT
	    # partition.
	    options=&quot;-t efi-raw --system=x86_64-linux&quot;;;
	*)
	    options=&quot;&quot;
	    ;;
    esac
    guix system -n image $options &quot;$example&quot;
done

# Make sure the desktop image can be built on major architectures.
for system in x86_64-linux aarch64-linux
do
    guix system -n image -s &quot;$system&quot; -t efi-raw \
	 gnu/system/examples/desktop.tmpl
done

# Verify that the images can be built.
guix system -n vm gnu/system/examples/bare-bones.tmpl
guix system -n image gnu/system/images/pinebook-pro.scm
guix system -n image -t qcow2 gnu/system/examples/bare-bones.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 &quot;raw&quot;
</pre>
</div></div> <!-- class=content -->
                         <div class=footer>generated by
                             <a href="https://git.zx2c4.com/cgit/about/">
                                 cgit
                             </a>
                         </div>
                        </div> <!-- id=cgit -->
</body>
</html>
