nixpkgs/pkgs/build-support/docker/pull.nix

33 lines
930 B
Nix
Raw Normal View History

2017-05-26 17:06:24 +01:00
{ stdenv, lib, docker, vmTools, utillinux, curl, kmod, dhcp, cacert, e2fsprogs }:
let
nameReplace = name: builtins.replaceStrings ["/" ":"] ["-" "-"] name;
in
# For simplicity we only support sha256.
2017-05-26 17:06:24 +01:00
{ imageName, imageTag ? "latest", imageId ? "${imageName}:${imageTag}"
, sha256, name ? (nameReplace "docker-image-${imageName}-${imageTag}.tar") }:
let
pullImage = vmTools.runInLinuxVM (
stdenv.mkDerivation {
inherit name imageId;
2017-05-26 17:06:24 +01:00
certs = "${cacert}/etc/ssl/certs/ca-bundle.crt";
2017-05-26 17:06:24 +01:00
builder = ./pull.sh;
2017-05-26 17:06:24 +01:00
buildInputs = [ curl utillinux docker kmod dhcp cacert e2fsprogs ];
2017-05-26 17:06:24 +01:00
outputHashAlgo = "sha256";
outputHash = sha256;
2017-05-26 17:06:24 +01:00
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
2017-05-26 17:06:24 +01:00
preVM = vmTools.createEmptyImage {
size = 2048;
fullName = "${name}-disk";
};
2017-05-26 17:06:24 +01:00
QEMU_OPTS = "-netdev user,id=net0 -device virtio-net-pci,netdev=net0";
});
in
pullImage