| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 |
|
| 21 | |
| 22 | |
| 23 | |
| 24 |
|
| 25 | set -e
|
| 26 |
|
| 27 | guix system --version
|
| 28 |
|
| 29 | tmpfile="t-guix-system-$$"
|
| 30 | errorfile="t-guix-system-error-$$"
|
| 31 |
|
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | tmpdir="${TMPDIR:-/tmp}/t-guix-system-$$"
|
| 37 | mkdir "$tmpdir"
|
| 38 |
|
| 39 | trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT
|
| 40 |
|
| 41 | |
| 42 |
|
| 43 | cat > "$tmpfile"<<EOF
|
| 44 | ;; This is line 1, and the next one is line 2.
|
| 45 | (operating-system)
|
| 46 | ;; The 'T' is at column 3.
|
| 47 | EOF
|
| 48 |
|
| 49 | if guix system vm "$tmpfile" 2> "$errorfile"
|
| 50 | then
|
| 51 | |
| 52 | exit 1
|
| 53 | else
|
| 54 | cat "$errorfile"
|
| 55 | grep "$tmpfile:2:3:.*missing.* initializers" "$errorfile"
|
| 56 | fi
|
| 57 |
|
| 58 |
|
| 59 | cat > "$tmpfile"<<EOF
|
| 60 | ;; This is line 1, and the next one is line 2.
|
| 61 | (operating-system
|
| 62 | ;; This is line 3, and there is no closing paren!
|
| 63 | EOF
|
| 64 |
|
| 65 | if guix system vm "$tmpfile" 2> "$errorfile"
|
| 66 | then
|
| 67 | |
| 68 | exit 1
|
| 69 | else
|
| 70 | cat "$errorfile"
|
| 71 |
|
| 72 | |
| 73 | |
| 74 | grep "$tmpfile:4:1: missing closing paren" "$errorfile" || \
|
| 75 | grep "$tmpfile:3:0: missing closing paren" "$errorfile"
|
| 76 | fi
|
| 77 |
|
| 78 |
|
| 79 | |
| 80 |
|
| 81 | cat > "$tmpfile" <<EOF
|
| 82 | ;; Line 1.
|
| 83 | (use-modules (gnu))
|
| 84 | (use-service-modules openssh)
|
| 85 | EOF
|
| 86 |
|
| 87 | if guix system build "$tmpfile" -n 2> "$errorfile"
|
| 88 | then false
|
| 89 | else
|
| 90 | grep "$tmpfile:3:2: .*module .*openssh.*not found" "$errorfile"
|
| 91 | grep "Try.*use-service-modules ssh" "$errorfile"
|
| 92 | fi
|
| 93 |
|
| 94 | cat > "$tmpfile" <<EOF
|
| 95 | ;; Line 1.
|
| 96 | (use-modules (gnu))
|
| 97 | (use-package-modules qemu)
|
| 98 | EOF
|
| 99 |
|
| 100 | if guix system build "$tmpfile" -n 2> "$errorfile"
|
| 101 | then false
|
| 102 | else
|
| 103 | grep "$tmpfile:3:2: .*module .*qemu.*not found" "$errorfile"
|
| 104 | grep "Try.*use-package-modules virtualization" "$errorfile"
|
| 105 | fi
|
| 106 |
|
| 107 | |
| 108 |
|
| 109 | cat > "$tmpfile" <<EOF
|
| 110 | (use-modules (gnu)) ; 1
|
| 111 | (use-service-modules networking) ; 2
|
| 112 |
|
| 113 | (operating-system ; 4
|
| 114 | (host-name "antelope") ; 5
|
| 115 | (timezone "Europe/Paris") ; 6
|
| 116 | (locale "en_US.UTF-8") ; 7
|
| 117 |
|
| 118 | (bootloader (GRUB-config (targets (list "/dev/sdX")))) ; 9
|
| 119 | (file-systems (cons (file-system
|
| 120 | (device (file-system-label "root"))
|
| 121 | (mount-point "/")
|
| 122 | (type "ext4"))
|
| 123 | %base-file-systems)))
|
| 124 | EOF
|
| 125 |
|
| 126 | if guix system build "$tmpfile" -n 2> "$errorfile"
|
| 127 | then false
|
| 128 | else
|
| 129 | if test "`guile -c '(display (effective-version))'`" = 3.0
|
| 130 | then
|
| 131 | |
| 132 | |
| 133 | grep "$tmpfile:[0-9]\+:[0-9]\+:.*GRUB-config.*[Uu]nbound variable" "$errorfile"
|
| 134 | elif test "`guile -c '(display (effective-version))'`" = 2.2
|
| 135 | then
|
| 136 | |
| 137 | |
| 138 | grep "$tmpfile:[49]:[0-9]\+:.*GRUB-config.*[Uu]nbound variable" "$errorfile"
|
| 139 | else
|
| 140 | grep "$tmpfile:9:[0-9]\+:.*GRUB-config.*[Uu]nbound variable" "$errorfile"
|
| 141 | fi
|
| 142 | fi
|
| 143 |
|
| 144 | cat > "$tmpfile" <<EOF
|
| 145 | (use-modules (gnu)) ; 1
|
| 146 |
|
| 147 | (operating-system ; 3
|
| 148 | (file-systems (cons (file-system ; 4
|
| 149 | (device (file-system-label "root"))
|
| 150 | (mount-point "/") ; 6
|
| 151 | (type "ext4")))) ; 7 (!!)
|
| 152 | %base-file-systems)
|
| 153 | EOF
|
| 154 |
|
| 155 | if guix system build "$tmpfile" -n 2> "$errorfile"
|
| 156 | then false
|
| 157 | else
|
| 158 | |
| 159 | |
| 160 | grep "$tmpfile:3:[0-9]\+:.*%base-file-system.*invalid field specifier" \
|
| 161 | "$errorfile"
|
| 162 | fi
|
| 163 |
|
| 164 | OS_BASE='
|
| 165 | (host-name "antelope")
|
| 166 | (timezone "Europe/Paris")
|
| 167 | (locale "en_US.UTF-8")
|
| 168 |
|
| 169 | (bootloader (bootloader-configuration
|
| 170 | (bootloader grub-bootloader)
|
| 171 | (targets (list "/dev/sdX"))))
|
| 172 | (file-systems (cons (file-system
|
| 173 | (device (file-system-label "root"))
|
| 174 | (mount-point "/")
|
| 175 | (type "ext4"))
|
| 176 | %base-file-systems))
|
| 177 | '
|
| 178 |
|
| 179 | |
| 180 |
|
| 181 | cat > "$tmpfile" <<EOF
|
| 182 | (use-modules (gnu))
|
| 183 | (use-service-modules networking)
|
| 184 |
|
| 185 | (operating-system
|
| 186 | $OS_BASE
|
| 187 | (services (cons* (service dhcpcd-service-type)
|
| 188 | (service dhcpcd-service-type) ;twice!
|
| 189 | %base-services)))
|
| 190 | EOF
|
| 191 |
|
| 192 | if guix system vm "$tmpfile" 2> "$errorfile"
|
| 193 | then
|
| 194 | |
| 195 | exit 1
|
| 196 | else
|
| 197 | grep "service 'networking'.*more than once" "$errorfile"
|
| 198 | fi
|
| 199 |
|
| 200 | |
| 201 |
|
| 202 | cat > "$tmpfile" <<EOF
|
| 203 | (use-modules (gnu) (gnu services shepherd))
|
| 204 | (use-service-modules networking)
|
| 205 |
|
| 206 | (define buggy-service-type
|
| 207 | (shepherd-service-type
|
| 208 | 'buggy
|
| 209 | (lambda _
|
| 210 | (shepherd-service
|
| 211 | (provision '(buggy!))
|
| 212 | (requirement '(does-not-exist))
|
| 213 | (start #t)))
|
| 214 | (description "Buggy.")))
|
| 215 |
|
| 216 | (operating-system
|
| 217 | $OS_BASE
|
| 218 | (services (cons (service buggy-service-type #t)
|
| 219 | %base-services)))
|
| 220 | EOF
|
| 221 |
|
| 222 | if guix system build "$tmpfile" 2> "$errorfile"
|
| 223 | then
|
| 224 | exit 1
|
| 225 | else
|
| 226 | grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile"
|
| 227 | fi
|
| 228 |
|
| 229 | |
| 230 |
|
| 231 | make_user_config ()
|
| 232 | {
|
| 233 | cat > "$tmpfile" <<EOF
|
| 234 | (use-modules (gnu))
|
| 235 | (use-service-modules networking)
|
| 236 |
|
| 237 | (operating-system
|
| 238 | (host-name "antelope")
|
| 239 | (timezone "Europe/Paris")
|
| 240 | (locale "en_US.UTF-8")
|
| 241 |
|
| 242 | (bootloader (bootloader-configuration
|
| 243 | (bootloader grub-bootloader)
|
| 244 | (targets (list "/dev/sdX"))))
|
| 245 | (file-systems (cons (file-system
|
| 246 | (device (file-system-label "root"))
|
| 247 | (mount-point "/")
|
| 248 | (type "ext4"))
|
| 249 | %base-file-systems))
|
| 250 | (users (list (user-account
|
| 251 | (name "dave")
|
| 252 | (home-directory "/home/dave")
|
| 253 | (group "$1")
|
| 254 | (supplementary-groups '("$2"))))))
|
| 255 | EOF
|
| 256 | }
|
| 257 |
|
| 258 | make_user_config "users" "wheel"
|
| 259 | guix system build "$tmpfile" -n |
| 260 |
|
| 261 | guix system build "$tmpfile" -d |
| 262 | guix system build "$tmpfile" -d | grep '\.drv$'
|
| 263 |
|
| 264 | guix system vm "$tmpfile" -d |
| 265 | guix system vm "$tmpfile" -d | grep '\.drv$'
|
| 266 |
|
| 267 | |
| 268 | drv1="`guix system vm "$tmpfile" -d`"
|
| 269 | drv2="`guix system vm "$tmpfile" -d`"
|
| 270 | test "$drv1" = "$drv2"
|
| 271 | drv1="`guix system image -t iso9660 "$tmpfile" -d`"
|
| 272 | drv2="`guix system image -t iso9660 "$tmpfile" -d`"
|
| 273 | test "$drv1" = "$drv2"
|
| 274 |
|
| 275 | |
| 276 | guix system extension-graph "$tmpfile" | grep 'label = "file-systems"'
|
| 277 | guix system shepherd-graph "$tmpfile" | grep 'label = "guix-daemon"'
|
| 278 |
|
| 279 | make_user_config "group-that-does-not-exist" "users"
|
| 280 | if guix system build "$tmpfile" -n 2> "$errorfile"
|
| 281 | then false
|
| 282 | else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
|
| 283 |
|
| 284 | make_user_config "users" "group-that-does-not-exist"
|
| 285 | if guix system build "$tmpfile" -n 2> "$errorfile"
|
| 286 | then false
|
| 287 | else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
|
| 288 |
|
| 289 | |
| 290 |
|
| 291 | cat > "$tmpdir/config.scm"<<EOF
|
| 292 | (use-modules (gnu))
|
| 293 | (use-service-modules networking)
|
| 294 |
|
| 295 | (operating-system
|
| 296 | $OS_BASE
|
| 297 | (services (cons (service tor-service-type
|
| 298 | (tor-configuration
|
| 299 | (config-file (local-file "my-torrc"))))
|
| 300 | %base-services)))
|
| 301 | EOF
|
| 302 |
|
| 303 | cat > "$tmpdir/my-torrc"<<EOF
|
| 304 | # This is an example file.
|
| 305 | EOF
|
| 306 |
|
| 307 | |
| 308 | guix system build "$tmpdir/config.scm" -n
|
| 309 | (cd "$tmpdir"; guix system build "config.scm" -n)
|
| 310 |
|
| 311 | |
| 312 | |
| 313 | cat > "$tmpdir/config.scm" <<EOF
|
| 314 | (use-modules (guix))
|
| 315 |
|
| 316 | (define (bad-local-file file)
|
| 317 | (local-file file))
|
| 318 |
|
| 319 | (bad-local-file "whatever.scm")
|
| 320 | EOF
|
| 321 | guix system build "$tmpdir/config.scm" -n && false
|
| 322 | guix system build "$tmpdir/config.scm" -n 2>&1 | \
|
| 323 | grep "config\.scm:4:2: warning:.*whatever.*relative to current directory"
|
| 324 |
|
| 325 | |
| 326 | guix system search tor | grep "^name: tor"
|
| 327 | guix system search tor | grep "^shepherdnames: tor"
|
| 328 | guix system search anonym network | grep "^name: tor"
|
| 329 | guix system search . > "$tmpdir/search"
|
| 330 | test $(wc -l < "$tmpdir/search") -gt 500
|
| 331 | rm "$tmpdir/search"
|
| 332 |
|
| 333 | |
| 334 | |
| 335 |
|
| 336 | |
| 337 | for example in gnu/system/examples/*.tmpl; do
|
| 338 | case "$example" in
|
| 339 | *hurd*)
|
| 340 | options="--target=i586-pc-gnu";;
|
| 341 | *asus*)
|
| 342 | |
| 343 | |
| 344 | options="--system=armhf-linux";;
|
| 345 | *raspberry*)
|
| 346 | |
| 347 | |
| 348 | options="--system=aarch64-linux";;
|
| 349 | *plasma*)
|
| 350 | |
| 351 | |
| 352 | options="--system=x86_64-linux";;
|
| 353 | *vm-image*)
|
| 354 | |
| 355 | |
| 356 | continue
|
| 357 | ;;
|
| 358 | *desktop*)
|
| 359 | |
| 360 | |
| 361 | options="-t efi-raw --system=x86_64-linux";;
|
| 362 | *)
|
| 363 | options=""
|
| 364 | ;;
|
| 365 | esac
|
| 366 | guix system -n image $options "$example"
|
| 367 | done
|
| 368 |
|
| 369 | |
| 370 | for system in x86_64-linux aarch64-linux
|
| 371 | do
|
| 372 | guix system -n image -s "$system" -t efi-raw \
|
| 373 | gnu/system/examples/desktop.tmpl
|
| 374 | done
|
| 375 |
|
| 376 | |
| 377 | guix system -n container gnu/system/examples/bare-bones.tmpl
|
| 378 | guix system -n vm gnu/system/examples/bare-bones.tmpl
|
| 379 | guix system -n image gnu/system/images/pinebook-pro.scm
|
| 380 | guix system -n image -t qcow2 gnu/system/examples/bare-bones.tmpl
|
| 381 | guix system -n image -t iso9660 gnu/system/examples/bare-bones.tmpl
|
| 382 | guix system -n docker-image gnu/system/examples/docker-image.tmpl
|
| 383 |
|
| 384 | |
| 385 | guix system --list-image-types | grep "raw"
|