fix(nix/buildGo): fix for Nix >= 2.6 readFile changes

The string context retained by readFile would leak into attribute keys
in fromJSON which may not have string context in any Nix version. We
don't need Nix >= 2.6 support, but buildGo may have external users and
this change is simple enough.

Change-Id: I593f1ef513502691119428d26d508a5f4d378543
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6946
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
sterni 2022-10-11 14:32:51 +02:00 committed by clbot
parent fcd5e53703
commit 81fadbe6eb

View file

@ -13,6 +13,7 @@ let
readFile readFile
replaceStrings replaceStrings
tail tail
unsafeDiscardStringContext
throw; throw;
inherit (pkgs) lib runCommand go jq ripgrep; inherit (pkgs) lib runCommand go jq ripgrep;
@ -102,7 +103,9 @@ let
analysisOutput = runCommand "${name}-structure.json" { } '' analysisOutput = runCommand "${name}-structure.json" { } ''
${analyser}/bin/analyser -path ${path} -source ${src} > $out ${analyser}/bin/analyser -path ${path} -source ${src} > $out
''; '';
analysis = fromJSON (readFile analysisOutput); # readFile adds the references of the read in file to the string context for
# Nix >= 2.6 which would break the attribute set construction in fromJSON
analysis = fromJSON (unsafeDiscardStringContext (readFile analysisOutput));
in in
lib.fix (self: foldl' lib.recursiveUpdate { } ( lib.fix (self: foldl' lib.recursiveUpdate { } (
map (entry: mkset entry.locator (toPackage self src path depMap entry)) analysis map (entry: mkset entry.locator (toPackage self src path depMap entry)) analysis