1 { stdenv, lib, coreutils, bash, gnutar, writeText }:
4 builtins.replaceStrings [ "https://" "http://" ] [ "" "" ];
6 s: lib.removePrefix "${builtins.storeDir}/" s;
9 , registry ? "https://registry-1.docker.io/v2/"
10 , repository ? "library"
15 , image ? "${stripScheme registry}/${repository}/${imageName}:${tag}"
18 # Make sure there are *no* slashes in the repository or container
19 # names since we use these to make the output derivation name for the
21 assert null == lib.findFirst (c: "/"==c) null (lib.stringToCharacters repository);
22 assert null == lib.findFirst (c: "/"==c) null (lib.stringToCharacters imageName);
25 # Abuse paths to collapse possible double slashes
26 repoTag0 = builtins.toString (/. + "/${stripScheme registry}/${repository}/${imageName}");
27 repoTag1 = lib.removePrefix "/" repoTag0;
29 layers = builtins.map stripNixStore imageLayers;
32 writeText "manifest.json" (builtins.toJSON [
33 { Config = stripNixStore imageConfig;
35 RepoTags = [ "${repoTag1}:${tag}" ];
39 writeText "repositories" (builtins.toJSON {
41 ${tag} = lib.last layers;
46 writeText "imageFileStorePaths.txt"
47 (lib.concatStringsSep "\n" ((lib.unique imageLayers) ++ [imageConfig]));
50 builder = ./fetchdocker-builder.sh;
51 buildInputs = [ coreutils ];
52 preferLocalBuild = true;
54 inherit name imageName repository tag;
55 inherit bash gnutar manifest repositories;
56 inherit imageFileStorePaths;