fix(nixery): Discard string context before parsing with fromJSON

Discard string context in prepare-image.nix before parsing input read
with readFile with fromJSON. Required for compatibility with nix >2.3.

Change-Id: I3830707e80fd19a700551a15f1a96d2841d0b022
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6696
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
talyz 2022-09-19 11:46:38 +02:00
parent 28417afbb4
commit 02b6b6c564

View file

@ -155,7 +155,7 @@ let
# Metadata about the symlink layer which is required for serving it. # Metadata about the symlink layer which is required for serving it.
# Two different hashes are computed for different usages (inclusion # Two different hashes are computed for different usages (inclusion
# in manifest vs. content-checking in the layer cache). # in manifest vs. content-checking in the layer cache).
symlinkLayerMeta = fromJSON (readFile (runCommand "symlink-layer-meta.json" symlinkLayerMeta = fromJSON (builtins.unsafeDiscardStringContext (readFile (runCommand "symlink-layer-meta.json"
{ {
buildInputs = [ coreutils jq openssl ]; buildInputs = [ coreutils jq openssl ];
} '' } ''
@ -164,11 +164,11 @@ let
jq -n -c --arg tarHash $tarHash --arg size $layerSize --arg path ${symlinkLayer} \ jq -n -c --arg tarHash $tarHash --arg size $layerSize --arg path ${symlinkLayer} \
'{ size: ($size | tonumber), tarHash: $tarHash, path: $path }' >> $out '{ size: ($size | tonumber), tarHash: $tarHash, path: $path }' >> $out
'')); '')));
# Final output structure returned to Nixery if the build succeeded # Final output structure returned to Nixery if the build succeeded
buildOutput = { buildOutput = {
runtimeGraph = fromJSON (readFile runtimeGraph); runtimeGraph = fromJSON (builtins.unsafeDiscardStringContext (readFile runtimeGraph));
symlinkLayer = symlinkLayerMeta; symlinkLayer = symlinkLayerMeta;
}; };