From 72f462bdbafac035a1633fe064549089c6281ecd Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 20 Nov 2024 05:52:51 +0100 Subject: [PATCH] pkgs/top-level/release.nix: Don't include non-Hydra attributes with attrNamesOnly The attrNamesOnly feature is used by pkgs/top-level/release-attrpaths-superset.nix to return a superset of all attributes that might be built by Hydra. Before this change it would include all attribute paths to derivations that could be found recursively, ignoring the recurseForDerivations and recurseForRelease attributes that control Hydra's recursion. This had the effect that it would end up with ~266000 attributes, most of which definitely won't be built by Hydra. We can remove those while staying true to the superset notion to end up with just ~97000, a reduction of ~63.6%! This also comes with an eval time reduction from 31.7s to 18.7s (-41.0%)! As an example, all derivations in pypy310Packages don't get included anymore, because it doesn't have a `.recurseForDerivations` set. As a nice side effect, with `--arg enableWarnings false`, no more warnings are printed, because things like `checkpointBuildTools.mkCheckpointedBuild` (which is deprecated) isn't being recursed to anymore. --- pkgs/top-level/release-lib.nix | 23 ++++++++++++++++------- pkgs/top-level/release.nix | 9 +++++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/pkgs/top-level/release-lib.nix b/pkgs/top-level/release-lib.nix index 41221f8b89f3..c7581c47d341 100644 --- a/pkgs/top-level/release-lib.nix +++ b/pkgs/top-level/release-lib.nix @@ -163,19 +163,26 @@ let (addMetaAttrs { maintainers = crossMaintainers; }); - /* Recursively map a (nested) set of derivations to an isomorphic - set of meta.platforms values. */ - packagePlatforms = mapAttrs (name: value: + /* Recursive for packages and apply a function to them */ + recursiveMapPackages = f: mapAttrs (name: value: if isDerivation value then - value.meta.hydraPlatforms - or (subtractLists (value.meta.badPlatforms or []) - (value.meta.platforms or supportedSystems)) + f value else if value.recurseForDerivations or false || value.recurseForRelease or false then - packagePlatforms value + recursiveMapPackages f value else [] ); + /* Gets the list of Hydra platforms for a derivation */ + getPlatforms = drv: + drv.meta.hydraPlatforms + or (subtractLists (drv.meta.badPlatforms or []) + (drv.meta.platforms or supportedSystems)); + + /* Recursively map a (nested) set of derivations to an isomorphic + set of meta.platforms values. */ + packagePlatforms = recursiveMapPackages getPlatforms; + in { /* Common platform groups on which to test packages. */ inherit (platforms) unix linux darwin cygwin all; @@ -188,6 +195,8 @@ in { lib mapTestOn mapTestOnCross + recursiveMapPackages + getPlatforms packagePlatforms pkgs pkgsFor diff --git a/pkgs/top-level/release.nix b/pkgs/top-level/release.nix index 3d9de8660282..a8e65a6a7415 100644 --- a/pkgs/top-level/release.nix +++ b/pkgs/top-level/release.nix @@ -321,8 +321,9 @@ let # Conflicts usually cause silent job drops like in # https://github.com/NixOS/nixpkgs/pull/182058 jobs = let - packagePlatforms = if attrNamesOnly then id else release-lib.packagePlatforms; - packageJobs = { + packagePlatforms = release-lib.recursiveMapPackages + (if attrNamesOnly then id else release-lib.getPlatforms); + packageJobs = packagePlatforms pkgs // { haskell.compiler = packagePlatforms pkgs.haskell.compiler; haskellPackages = packagePlatforms pkgs.haskellPackages; # Build selected packages (HLS) for multiple Haskell compilers to rebuild @@ -363,8 +364,8 @@ let }; mapTestOn-packages = if attrNamesOnly - then pkgs // packageJobs - else mapTestOn ((packagePlatforms pkgs) // packageJobs); + then packageJobs + else mapTestOn packageJobs; in unionOfDisjoint nonPackageJobs mapTestOn-packages;