about summary refs log tree commit diff
path: root/nix/buildGo
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-10-11T12·32+0200
committerclbot <clbot@tvl.fyi>2022-10-11T17·38+0000
commit81fadbe6eb037cbbe08e35ea692fd1dbe993f354 (patch)
tree6ece6d1d391d9f1d5abb28582acb2dd5a416f08f /nix/buildGo
parentfcd5e5370320d934f371bb96069a4719e94aafcd (diff)
fix(nix/buildGo): fix for Nix >= 2.6 readFile changes r/5106
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
Diffstat (limited to 'nix/buildGo')
-rw-r--r--nix/buildGo/external/default.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/nix/buildGo/external/default.nix b/nix/buildGo/external/default.nix
index f713783a58..42592c67e4 100644
--- a/nix/buildGo/external/default.nix
+++ b/nix/buildGo/external/default.nix
@@ -13,6 +13,7 @@ let
     readFile
     replaceStrings
     tail
+    unsafeDiscardStringContext
     throw;
 
   inherit (pkgs) lib runCommand go jq ripgrep;
@@ -102,7 +103,9 @@ let
   analysisOutput = runCommand "${name}-structure.json" { } ''
     ${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
 lib.fix (self: foldl' lib.recursiveUpdate { } (
   map (entry: mkset entry.locator (toPackage self src path depMap entry)) analysis