anchor.diff:          };
           inherit fromImage fromImageName fromImageTag;
   
  -        buildInputs = [ utillinux e2fsprogs jshon rsync ];
  +        buildInputs = [ utillinux e2fsprogs jshon rsync jq ];
         } ''
         rm -rf $out
   
  
positive.code:         tar -rpf temp/layer.tar --mtime="@$SOURCE_DATE_EPOCH" \
            --owner=0 --group=0 --no-recursion --files-from newFiles
  
          echo "Adding meta..."
  
          # If we have a parentID, add it to the json metadata.
          if [[ -n "$parentID" ]]; then
            cat temp/json | jshon -s "$parentID" -i parent > tmpjson
            mv tmpjson temp/json
          fi
  
          # Take the sha256 sum of the generated json and use it as the layer ID.
          # Compute the size and add it to the json under the 'Size' field.
          layerID=$(sha256sum temp/json|cut -d ' ' -f 1)
          size=$(stat --printf="%s" temp/layer.tar)
          cat temp/json | jshon -s "$layerID" -i id -n $size -i Size > tmpjson
          mv tmpjson temp/json
  
          # Use the temp folder we've been working on to create a new image.
          mv temp image/$layerID
  
          # Create image json and image manifest
          imageJson=$(cat ${baseJson} | jq ". + {\"rootfs\": {\"diff_ids\": [], \"type\": \"layers\"}}")
          manifestJson=$(jq -n "[{\"RepoTags\":[\"$imageName:$imageTag\"]}]")
          currentID=$layerID
          while [[ -n "$currentID" ]]; do
            layerChecksum=$(sha256sum image/$currentID/layer.tar | cut -d ' ' -f1)
            imageJson=$(echo "$imageJson" | jq ".history |= [{\"created\": \"${created}\"}] + .")
            imageJson=$(echo "$imageJson" | jq ".rootfs.diff_ids |= [\"sha256:$layerChecksum\"] + .")
            manifestJson=$(echo "$manifestJson" | jq ".[0].Layers |= [\"$currentID/layer.tar\"] + .")
  
            currentID=$(cat image/$currentID/json | (jshon -e parent -u 2>/dev/null || true))
          done
  
          imageJsonChecksum=$(echo "$imageJson" | sha256sum | cut -d ' ' -f1)
          echo "$imageJson" > "image/$imageJsonChecksum.json"
          manifestJson=$(echo "$manifestJson" | jq ".[0].Config = \"$imageJsonChecksum.json\"")
          echo "$manifestJson" > image/manifest.json
  
          # Store the json under the name image/repositories.
          jshon -n object \
            -n object -s "$layerID" -i "$imageTag" \
            -i "$imageName" > image/repositories
  
          # Make the image read-only.
          chmod -R a-w image
  
negative.code:       mount /dev/${vmTools.hd} disk
        cd disk
  
        layers=""
        if [[ -n "$fromImage" ]]; then
          echo "Unpacking base image..."
          mkdir image
          tar -C image -xpf "$fromImage"
          layers=$(jq -r '.[0].Layers | join(" ")' image/manifest.json)
        fi
  
        # Unpack all of the layers into the image.
        # Layer list is ordered starting from the base image
        lowerdir=""
        for layer in $layers; do
          echo "Unpacking layer $layer"
          layerDir=image/$(echo $layer | cut -d':' -f2)"_unpacked"
          mkdir -p $layerDir
          tar -C $layerDir -xpf image/$layer
          chmod a+w image/$layer
          rm image/$layer
  
          find $layerDir -name ".wh.*" -exec bash -c 'name="$(basename {}|sed "s/^.wh.//")"; mknod "$(dirname {})/$name" c 0 0; rm {}' \;
  
          # Get the next lower directory and continue the loop.
          lowerdir=$lowerdir''${lowerdir:+:}$layerDir
        done
  
        mkdir work
  