From 81fadbe6eb037cbbe08e35ea692fd1dbe993f354 Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 11 Oct 2022 14:32:51 +0200 Subject: 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 Reviewed-by: tazjin Tested-by: BuildkiteCI --- nix/buildGo/external/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nix/buildGo/external/default.nix b/nix/buildGo/external/default.nix index f713783a58be..42592c67e482 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 -- cgit 1.4.1