From 9e0a97e02654b788ccdfaafe2c719bc0f8411cd6 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 13 Apr 2023 21:32:21 +1200 Subject: [PATCH] No special treatment for hydraJobs --- lib.nix | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/lib.nix b/lib.nix index a66410d..17dbba2 100644 --- a/lib.nix +++ b/lib.nix @@ -26,53 +26,19 @@ let # eachSystem using defaultSystems eachDefaultSystem = eachSystem defaultSystems; - # Builds a map from =value to .=value for each system, - # except for the `hydraJobs` attribute, where it maps the inner attributes, - # from hydraJobs.=value to hydraJobs..=value. + # Builds a map from =value to .=value for each system # eachSystem = systems: f: let - # Taken from - isDerivation = x: builtins.isAttrs x && x ? type && x.type == "derivation"; - - # Used to match Hydra's convention of how to define jobs. Basically transforms - # - # hydraJobs = { - # hello = ; - # haskellPackages.aeson = ; - # } - # - # to - # - # hydraJobs = { - # hello.x86_64-linux = ; - # haskellPackages.aeson.x86_64-linux = ; - # } - # - # if the given flake does `eachSystem [ "x86_64-linux" ] { ... }`. - pushDownSystem = system: merged: - builtins.mapAttrs - (name: value: - if ! (builtins.isAttrs value) then value - else if isDerivation value then (merged.${name} or { }) // { ${system} = value; } - else pushDownSystem system (merged.${name} or { }) value); - # Merge together the outputs for all systems. op = attrs: system: let ret = f system; - op = attrs: key: - let - appendSystem = key: system: ret: - if key == "hydraJobs" - then (pushDownSystem system (attrs.hydraJobs or { }) ret.hydraJobs) - else { ${system} = ret.${key}; }; - in - attrs // - { - ${key} = (attrs.${key} or { }) - // (appendSystem key system ret); - } + op = attrs: key: attrs // + { + ${key} = (attrs.${key} or { }) + // { ${system} = ret.${key}; }; + } ; in builtins.foldl' op attrs (builtins.attrNames ret);