ci/eval/compare: fix reading store paths from json file

This suddenly appeared after updating Nix to v26, which then complained:

… while calling the 'fromJSON' builtin
  at
/home/runner/work/nixpkgs/nixpkgs/target/ci/eval/compare/default.nix:74:19:
    73|
    74|   getAttrs = dir: builtins.fromJSON (builtins.readFile
"${dir}/outpaths.json");
      |                   ^
    75|   beforeAttrs = getAttrs beforeResultDir;

… while evaluating the first argument passed to builtins.fromJSON

error: the string '{
  "AMB-plugins.aarch64-linux": {
    "out":
"/nix/store/faw59ba5p6h4b177n8q2ilb3hlm7xlc2-AMB-plugins-0.8.1"
  },
                  ....
  "zzuf.aarch64-linux": {
    "out": "/nix/store/bqvm1h7jfd8smgnjc1v1gpmbwdgvwy5g-zzuf-0.15"
  },
  "zzuf.x86_64-linux": {
    "out": "/nix/store/6qs4lnmzn1qlr3smqqxnmhnrcdcfiv6a-zzuf-0.15"
  }
}
' is not allowed to refer to a store path (such as
'134m2q047vsr9miwh5l227j7sh9jb130-jq-1.7.1-bin')

By discard the unsafe string context, we explicitly allow loading those
store paths. It's unclear why this blew up now, especially because I was
not possible to consistently replicate this locally, so far.
This commit is contained in:
Wolfgang Walther 2025-03-19 19:05:22 +01:00
parent a9d6503abc
commit 5b578b0679
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1

View File

@ -71,7 +71,15 @@ let
getLabels
;
getAttrs = dir: builtins.fromJSON (builtins.readFile "${dir}/outpaths.json");
getAttrs =
dir:
let
raw = builtins.readFile "${dir}/outpaths.json";
# The file contains Nix paths; we need to ignore them for evaluation purposes,
# else there will be a "is not allowed to refer to a store path" error.
data = builtins.unsafeDiscardStringContext raw;
in
builtins.fromJSON data;
beforeAttrs = getAttrs beforeResultDir;
afterAttrs = getAttrs afterResultDir;