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
26
27
28
29
30
31
32
33
34
35
36
37
38
| | with import ./. {};
let
makeSquashfs = (callPackage nixos/lib/make-squashfs.nix {}).override;
kernel' = linux_cros;
kernel = with import lib/kernel.nix { inherit lib; inherit (kernel') version; };
kernel'.override { structuredExtraConfig = {
VIRTIO_PCI = yes;
VIRTIO_BLK = yes;
VIRTIO_WL = yes;
SQUASHFS = yes;
DEVTMPFS_MOUNT = yes;
}; };
init = writeShellScript "init" ''
set -xe
${coreutils}/bin/mkdir /dev/pts /dev/shm
${utillinux}/bin/mount -t tmpfs none /tmp
${utillinux}/bin/mount -t devpts -o gid=4,mode=620 none /dev/pts
${utillinux}/bin/mount -t tmpfs none /dev/shm
export XDG_RUNTIME_DIR=/tmp
${sommelier}/bin/sommelier ${hello-wayland}/bin/hello-wayland
'';
rootfs = runCommand "rootfs" {} ''
mkdir dev bin tmp
ln -s ${dash}/bin/sh bin
(cat ${writeReferencesToFile init}; printf "%s\n" bin dev tmp) | xargs tar -cP --hard-dereference | ${squashfs-tools-ng}/bin/tar2sqfs $out
'';
in
writeShellScript "crosvm" ''
set -x
exec ${crosvm}/bin/crosvm run --wayland-sock=$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY -p init=${init} --root=${rootfs} ${kernel}/bzImage
''
|