From 4a736e5ede53881ed86078e8a31301ba0a62057f Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Fri, 24 Mar 2023 11:32:47 +0900 Subject: [PATCH] haskellPackages: small refactoring and comments to versionedCompilerJobs in release-haskell.nix --- pkgs/top-level/release-haskell.nix | 35 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/pkgs/top-level/release-haskell.nix b/pkgs/top-level/release-haskell.nix index 10673a02ad1d..c745615f20d9 100644 --- a/pkgs/top-level/release-haskell.nix +++ b/pkgs/top-level/release-haskell.nix @@ -128,13 +128,38 @@ let # ``` versionedCompilerJobs = config: mapTestOn { haskell.packages = - lib.mapAttrs - (ghc: jobs: + let + # Mapping function that takes an attrset of jobs, and + # removes all jobs that are not specified in config. + # + # For example, imagine a call to onlyConfigJobs like: + # + # ``` + # onlyConfigJobs + # "ghc902" + # { + # conduit = [ ... ]; + # lens = [ "i686-cygwin" "x86_64-cygwin" ... "x86_64-windows" "i686-windows" ]; + # } + # ``` + # + # onlyConfigJobs pulls out only those jobs that are specified in config. + # + # For instance, if config is `{ lens = [ "ghc902" ]; }`, then the above + # example call to onlyConfigJobs will return: + # + # ``` + # { lens = [ "i686-cygwin" "x86_64-cygwin" ... "x86_64-windows" "i686-windows" ]; } + # ``` + # + # If config is `{ lens = [ "ghc8107" ]; }`, then the above example call + # to onlyConfigJobs returns `{}`. + onlyConfigJobs = ghc: jobs: lib.filterAttrs (jobName: platforms: lib.elem ghc (config."${jobName}" or [])) - jobs - ) - compilerPlatforms; + jobs; + in + lib.mapAttrs onlyConfigJobs compilerPlatforms; }; # hydra jobs for `pkgs` of which we import a subset of