1# Tests the contents attribute of nixos/lib/make-disk-image.nix
2# including its user, group, and mode attributes.
3{ system ? builtins.currentSystem,
4 config ? {},
5 pkgs ? import ../.. { inherit system config; }
6}:
7
8with import ../lib/testing-python.nix { inherit system pkgs; };
9with pkgs.lib;
10
11with import common/ec2.nix { inherit makeTest pkgs; };
12
13let
14 config = (import ../lib/eval-config.nix {
15 inherit system;
16 modules = [
17 ../modules/testing/test-instrumentation.nix
18 ../modules/profiles/qemu-guest.nix
19 {
20 fileSystems."/".device = "/dev/disk/by-label/nixos";
21 boot.loader.grub.device = "/dev/vda";
22 boot.loader.timeout = 0;
23 }
24 ];
25 }).config;
26 image = (import ../lib/make-disk-image.nix {
27 inherit pkgs config;
28 lib = pkgs.lib;
29 format = "qcow2";
30 contents = [{
31 source = pkgs.writeText "testFile" "contents";
32 target = "/testFile";
33 user = "1234";
34 group = "5678";
35 mode = "755";
36 }];
37 }) + "/nixos.qcow2";
38
39in makeEc2Test {
40 name = "image-contents";
41 inherit image;
42 userData = null;
43 script = ''
44 machine.start()
45 assert "content" in machine.succeed("cat /testFile")
46 fileDetails = machine.succeed("ls -l /testFile")
47 assert "1234" in fileDetails
48 assert "5678" in fileDetails
49 assert "rwxr-xr-x" in fileDetails
50 '';
51}