
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.
141 lines
4.1 KiB
Nix
141 lines
4.1 KiB
Nix
{
|
|
lib,
|
|
jq,
|
|
runCommand,
|
|
writeText,
|
|
...
|
|
}:
|
|
{
|
|
beforeResultDir,
|
|
afterResultDir,
|
|
touchedFilesJson,
|
|
}:
|
|
let
|
|
/*
|
|
Derivation that computes which packages are affected (added, changed or removed) between two revisions of nixpkgs.
|
|
Note: "platforms" are "x86_64-linux", "aarch64-darwin", ...
|
|
|
|
---
|
|
Inputs:
|
|
- beforeResultDir, afterResultDir: The evaluation result from before and after the change.
|
|
They can be obtained by running `nix-build -A ci.eval.full` on both revisions.
|
|
|
|
---
|
|
Outputs:
|
|
- changed-paths.json: Various information about the changes:
|
|
{
|
|
attrdiff: {
|
|
added: ["package1"],
|
|
changed: ["package2", "package3"],
|
|
removed: ["package4"],
|
|
},
|
|
labels: [
|
|
"10.rebuild-darwin: 1-10",
|
|
"10.rebuild-linux: 1-10"
|
|
],
|
|
rebuildsByKernel: {
|
|
darwin: ["package1", "package2"],
|
|
linux: ["package1", "package2", "package3"]
|
|
},
|
|
rebuildCountByKernel: {
|
|
darwin: 2,
|
|
linux: 3,
|
|
},
|
|
rebuildsByPlatform: {
|
|
aarch64-darwin: ["package1", "package2"],
|
|
aarch64-linux: ["package1", "package2"],
|
|
x86_64-linux: ["package1", "package2", "package3"],
|
|
x86_64-darwin: ["package1"],
|
|
},
|
|
}
|
|
- step-summary.md: A markdown render of the changes
|
|
|
|
---
|
|
Implementation details:
|
|
|
|
Helper functions can be found in ./utils.nix.
|
|
Two main "types" are important:
|
|
|
|
- `packagePlatformPath`: A string of the form "<PACKAGE_PATH>.<PLATFORM>"
|
|
Example: "python312Packages.numpy.x86_64-linux"
|
|
|
|
- `packagePlatformAttr`: An attrs representation of a packagePlatformPath:
|
|
Example: { name = "python312Packages.numpy"; platform = "x86_64-linux"; }
|
|
*/
|
|
inherit (import ./utils.nix { inherit lib; })
|
|
diff
|
|
groupByKernel
|
|
convertToPackagePlatformAttrs
|
|
groupByPlatform
|
|
extractPackageNames
|
|
getLabels
|
|
;
|
|
|
|
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;
|
|
|
|
# Attrs
|
|
# - keys: "added", "changed" and "removed"
|
|
# - values: lists of `packagePlatformPath`s
|
|
diffAttrs = diff beforeAttrs afterAttrs;
|
|
|
|
rebuilds = diffAttrs.added ++ diffAttrs.changed;
|
|
rebuildsPackagePlatformAttrs = convertToPackagePlatformAttrs rebuilds;
|
|
|
|
changed-paths =
|
|
let
|
|
rebuildsByPlatform = groupByPlatform rebuildsPackagePlatformAttrs;
|
|
rebuildsByKernel = groupByKernel rebuildsPackagePlatformAttrs;
|
|
rebuildCountByKernel = lib.mapAttrs (
|
|
kernel: kernelRebuilds: lib.length kernelRebuilds
|
|
) rebuildsByKernel;
|
|
in
|
|
writeText "changed-paths.json" (
|
|
builtins.toJSON {
|
|
attrdiff = lib.mapAttrs (_: extractPackageNames) diffAttrs;
|
|
inherit
|
|
rebuildsByPlatform
|
|
rebuildsByKernel
|
|
rebuildCountByKernel
|
|
;
|
|
labels =
|
|
(getLabels rebuildCountByKernel)
|
|
# Adds "10.rebuild-*-stdenv" label if the "stdenv" attribute was changed
|
|
++ lib.mapAttrsToList (kernel: _: "10.rebuild-${kernel}-stdenv") (
|
|
lib.filterAttrs (_: kernelRebuilds: kernelRebuilds ? "stdenv") rebuildsByKernel
|
|
);
|
|
}
|
|
);
|
|
|
|
maintainers = import ./maintainers.nix {
|
|
changedattrs = lib.attrNames (lib.groupBy (a: a.name) rebuildsPackagePlatformAttrs);
|
|
changedpathsjson = touchedFilesJson;
|
|
};
|
|
in
|
|
runCommand "compare"
|
|
{
|
|
nativeBuildInputs = [ jq ];
|
|
maintainers = builtins.toJSON maintainers;
|
|
passAsFile = [ "maintainers" ];
|
|
}
|
|
''
|
|
mkdir $out
|
|
|
|
cp ${changed-paths} $out/changed-paths.json
|
|
|
|
jq -r -f ${./generate-step-summary.jq} < ${changed-paths} > $out/step-summary.md
|
|
|
|
cp "$maintainersPath" "$out/maintainers.json"
|
|
|
|
# TODO: Compare eval stats
|
|
''
|