···83 };
8485 # 4. example of pulling an image. could be used as a base for other images
86- #
87- # ***** Currently broken, getting 404s. Perhaps the docker API has changed?
88- #
89- #
90- # debian = pullImage {
91- # imageName = "debian";
92- # imageTag = "jessie";
93- # # this hash will need change if the tag is updated at docker hub
94- # sha256 = "18kd495lc2k35h03bpcbdjnix17nlqbwf6nmq3sb161blf0dk14q";
95- # };
9697 # 5. example of multiple contents, emacs and vi happily coexisting
98 editors = buildImage {
···83 };
8485 # 4. example of pulling an image. could be used as a base for other images
86+ nix = pullImage {
87+ imageName = "nixos/nix";
88+ imageTag = "1.11";
89+ # this hash will need change if the tag is updated at docker hub
90+ sha256 = "1gk4bq05vl3rj3mh4mlbl4iicgndmimlv8jvkhdk4hrv0r44bwr3";
91+ };
00009293 # 5. example of multiple contents, emacs and vi happily coexisting
94 editors = buildImage {
+24-33
pkgs/build-support/docker/pull.nix
···1-{ stdenv, lib, curl, jshon, python, runCommand }:
2-3-# Inspired and simplified version of fetchurl.
04# For simplicity we only support sha256.
00000056-# Currently only registry v1 is supported, compatible with Docker Hub.
78-{ imageName, imageTag ? "latest", imageId ? null
9-, sha256, name ? "${imageName}-${imageTag}"
10-, indexUrl ? "https://index.docker.io"
11-, registryVersion ? "v1"
12-, curlOpts ? "" }:
1314-assert registryVersion == "v1";
1516-let layer = stdenv.mkDerivation {
17- inherit name imageName imageTag imageId
18- indexUrl registryVersion curlOpts;
1920- builder = ./pull.sh;
21- detjson = ./detjson.py;
2223- buildInputs = [ curl jshon python ];
24-25- outputHashAlgo = "sha256";
26- outputHash = sha256;
27- outputHashMode = "recursive";
28-29- impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
30- # This variable allows the user to pass additional options to curl
31- "NIX_CURL_FLAGS"
32- ];
33-34- # Doing the download on a remote machine just duplicates network
35- # traffic, so don't do that.
36- preferLocalBuild = true;
37-};
3839-in runCommand "${name}.tar.gz" {} ''
40- tar -C ${layer} -czf $out .
41-''
0