Collection of devkitpro toolchains compatible with Nix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB

{
image,
directory,
pkgs ? import <nixpkgs> {},
}:
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "docker-preload-image" {
memSize = 8 * 1024;
buildInputs = with pkgs; [
curl
kmod
docker
e2fsprogs
utillinux
];
}
''
modprobe overlay
# from https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
cd /sys/fs/cgroup
for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
mkdir -p $sys
if ! mountpoint -q $sys; then
if ! mount -n -t cgroup -o $sys cgroup $sys; then
rmdir $sys || true
fi
fi
done
dockerd -H tcp://127.0.0.1:5555 -H unix:///var/run/docker.sock &
until $(curl --output /dev/null --silent --connect-timeout 2 http://127.0.0.1:5555); do
printf '.'
sleep 1
done
echo load image
docker load -i ${image}
echo run image
docker run ${image.destNameTag} tar -C '${toString directory}' -c . | tar -xv --no-same-owner -C $out || true
echo end
kill %1
''
)