Unverified Commit 93c61c1e authored by WilliButz's avatar WilliButz
Browse files

nixos/repart-verity-store: include original roothashes in repart-output.json

parent 3f1f20b2
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ in
              nativeBuildInputs = previousAttrs.nativeBuildInputs ++ [
                pkgs.systemdUkify
                verityHashCheck
                pkgs.jq
              ];

              preBuild = ''
@@ -192,6 +193,24 @@ in
                chmod +w ${config.image.repart.imageFileBasename}.raw
              '';

              # replace "TBD" with the original roothash values
              preInstall = ''
                mv -v repart-output{.json,_orig.json}

                jq --slurp --indent -1 \
                  '.[0] as $intermediate | .[1] as $final
                    | $intermediate | map(select(.roothash != null) | { "uuid":.uuid,"roothash":.roothash }) as $uuids
                    | $final + $uuids
                    | group_by(.uuid)
                    | map(add)
                    | sort_by(.offset)' \
                      ${config.system.build.intermediateImage}/repart-output.json \
                      repart-output_orig.json \
                  > repart-output.json

                rm -v repart-output_orig.json
              '';

              # the image will be self-contained so we can drop references
              # to the closure that was used to build it
              unsafeDiscardReferences.out = true;