1# Take note the Guix store directory is empty. Also, we're trying to prevent
2# Guix from trying to downloading substitutes because of the restricted
3# access (assuming it's in a sandboxed environment).
4#
5# So this test is what it is: a basic test while trying to use Guix as much as
6# we possibly can (including the API) without triggering its download alarm.
7
8import ../make-test-python.nix (
9 { lib, pkgs, ... }:
10 {
11 name = "guix-basic";
12 meta.maintainers = with lib.maintainers; [ foo-dogsquared ];
13
14 nodes.machine =
15 { config, ... }:
16 {
17 environment.etc."guix/scripts".source = ./scripts;
18 services.guix = {
19 enable = true;
20 gc.enable = true;
21 };
22 };
23
24 testScript = ''
25 import pathlib
26
27 machine.wait_for_unit("multi-user.target")
28 machine.wait_for_unit("guix-daemon.service")
29 machine.succeed("systemctl start guix-gc.service")
30
31 # Can't do much here since the environment has restricted network access.
32 with subtest("Guix basic package management"):
33 machine.succeed("guix build --dry-run --verbosity=0 hello")
34 machine.succeed("guix show hello")
35
36 # This is to see if the Guix API is usable and mostly working.
37 with subtest("Guix API scripting"):
38 scripts_dir = pathlib.Path("/etc/guix/scripts")
39
40 text_msg = "Hello there, NixOS!"
41 text_store_file = machine.succeed(f"guix repl -- {scripts_dir}/create-file-to-store.scm '{text_msg}'")
42 assert machine.succeed(f"cat {text_store_file}") == text_msg
43
44 machine.succeed(f"guix repl -- {scripts_dir}/add-existing-files-to-store.scm {scripts_dir}")
45 '';
46 }
47)