@@ -249,7 +249,9 @@ rec {
249249 in map (x: [("closure-" + baseNameOf x) x]) contentsList;
250250 }
251251 ''
252− printRegistration=1 perl ${pkgs.pathsFromGraph} closure-* > $out
252+ mkdir $out
253+ printRegistration=1 perl ${pkgs.pathsFromGraph} closure-* > $out/db.dump
254+ perl ${pkgs.pathsFromGraph} closure-* > $out/storePaths
253255 '';
254256
255257 # Create a "layer" (set of files).
@@ -571,7 +573,23 @@ rec {
571573 echo " be better to only have one layer that contains a nix store."
572574 # This requires Nix 1.12 or higher
573575 export NIX_REMOTE=local?root=$PWD
574− ${nixUnstable}/bin/nix-store --load-db < ${nixRegistration contents}
576+ ${nixUnstable}/bin/nix-store --load-db < ${nixRegistration contents}/db.dump
577+
578+ # We fill the store in order to run the 'verify' command that
579+ # generates hash and size of output paths.
580+ # Note when Nix 1.12 is be the stable one, the database dump
581+ # generated by the exportReferencesGraph function will
582+ # contains sha and size. See
583+ # https://github.com/NixOS/nix/commit/c2b0d8749f7e77afc1c4b3e8dd36b7ee9720af4a
584+ storePaths=$(cat ${nixRegistration contents}/storePaths)
585+ echo "Copying everything to /nix/store (will take a while)..."
586+ cp -prd $storePaths nix/store/
587+ ${nixUnstable}/bin/nix-store --verify --check-contents
588+
589+ mkdir -p nix/var/nix/gcroots/docker/
590+ for i in ${lib.concatStringsSep " " contents}; do
591+ ln -s $i nix/var/nix/gcroots/docker/$(basename $i)
592+ done;
575593 '' + extraCommands;
576594 });
577595}