about summary refs log tree commit diff
path: root/pkgs/build-support/fetchdocker/fetchdocker-builder.sh
diff options
context:
space:
mode:
authorParnell Springmeyer <parnell@digitalmentat.com>2017-12-01 21:00:52 -0600
committerParnell Springmeyer <parnell@digitalmentat.com>2017-12-01 21:00:52 -0600
commit25865688a729d15dbb2dc21ebd9fbf74e2cffc4b (patch)
tree137ba921eb3a0eeefad4b6edab5c553c7c214a1a /pkgs/build-support/fetchdocker/fetchdocker-builder.sh
parentfdb8dea0c6440dfa8c6ffa6203ca2a6953fc2f6b (diff)
downloadnixlib-25865688a729d15dbb2dc21ebd9fbf74e2cffc4b.tar
nixlib-25865688a729d15dbb2dc21ebd9fbf74e2cffc4b.tar.gz
nixlib-25865688a729d15dbb2dc21ebd9fbf74e2cffc4b.tar.bz2
nixlib-25865688a729d15dbb2dc21ebd9fbf74e2cffc4b.tar.lz
nixlib-25865688a729d15dbb2dc21ebd9fbf74e2cffc4b.tar.xz
nixlib-25865688a729d15dbb2dc21ebd9fbf74e2cffc4b.tar.zst
nixlib-25865688a729d15dbb2dc21ebd9fbf74e2cffc4b.zip
docker: init fetchdocker nix code for docker2nix
This change adds granular, non-docker daemon docker image fetchers and
a docker image layer compositor to be used in conjunction with the
`docker2nix` utility provided by the `haskellPackages.hocker` package.

This change includes a hackage package version bump and updated sha256
for recent fixes released to `hocker` resulting from formulating this
patch.
Diffstat (limited to 'pkgs/build-support/fetchdocker/fetchdocker-builder.sh')
-rw-r--r--pkgs/build-support/fetchdocker/fetchdocker-builder.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchdocker/fetchdocker-builder.sh b/pkgs/build-support/fetchdocker/fetchdocker-builder.sh
new file mode 100644
index 000000000000..7443591e6569
--- /dev/null
+++ b/pkgs/build-support/fetchdocker/fetchdocker-builder.sh
@@ -0,0 +1,28 @@
+source "${stdenv}/setup"
+header "exporting ${repository}/${imageName} (tag: ${tag}) into ${out}"
+mkdir -p "${out}"
+
+cat <<EOF > "${out}/compositeImage.sh"
+#! ${bash}/bin/bash
+#
+# Create a tar archive of a docker image's layers, docker image config
+# json, manifest.json, and repositories json; this streams directly to
+# stdout and is intended to be used in concert with docker load, i.e:
+# 
+# ${out}/compositeImage.sh | docker load
+
+# The first character follow the 's' command for sed becomes the
+# delimiter sed will use; this makes the transformation regex easy to
+# read. We feed tar a file listing the files we want in the archive,
+# because the paths are absolute and docker load wants them flattened in
+# the archive, we need to transform all of the paths going in by
+# stripping everything *including* the last solidus so that we end up
+# with the basename of the path.
+${gnutar}/bin/tar \
+  --transform='s=.*/==' \
+  --transform="s=.*-manifest.json=manifest.json=" \
+  --transform="s=.*-repositories=repositories=" \
+  -c "${manifest}" "${repositories}" -T "${imageFileStorePaths}"
+EOF
+chmod +x "${out}/compositeImage.sh"
+stopNest