mirror of
https://github.com/numtide/flake-utils.git
synced 2025-03-16 21:38:26 +00:00
No special treatment for hydraJobs
This commit is contained in:
parent
a1720a10a6
commit
9e0a97e026
1 changed files with 6 additions and 40 deletions
46
lib.nix
46
lib.nix
|
@ -26,53 +26,19 @@ let
|
||||||
# eachSystem using defaultSystems
|
# eachSystem using defaultSystems
|
||||||
eachDefaultSystem = eachSystem defaultSystems;
|
eachDefaultSystem = eachSystem defaultSystems;
|
||||||
|
|
||||||
# Builds a map from <attr>=value to <attr>.<system>=value for each system,
|
# Builds a map from <attr>=value to <attr>.<system>=value for each system
|
||||||
# except for the `hydraJobs` attribute, where it maps the inner attributes,
|
|
||||||
# from hydraJobs.<attr>=value to hydraJobs.<attr>.<system>=value.
|
|
||||||
#
|
#
|
||||||
eachSystem = systems: f:
|
eachSystem = systems: f:
|
||||||
let
|
let
|
||||||
# Taken from <nixpkgs/lib/attrsets.nix>
|
|
||||||
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 = <derivation>;
|
|
||||||
# haskellPackages.aeson = <derivation>;
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# to
|
|
||||||
#
|
|
||||||
# hydraJobs = {
|
|
||||||
# hello.x86_64-linux = <derivation>;
|
|
||||||
# haskellPackages.aeson.x86_64-linux = <derivation>;
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# 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.
|
# Merge together the outputs for all systems.
|
||||||
op = attrs: system:
|
op = attrs: system:
|
||||||
let
|
let
|
||||||
ret = f system;
|
ret = f system;
|
||||||
op = attrs: key:
|
op = attrs: key: attrs //
|
||||||
let
|
{
|
||||||
appendSystem = key: system: ret:
|
${key} = (attrs.${key} or { })
|
||||||
if key == "hydraJobs"
|
// { ${system} = ret.${key}; };
|
||||||
then (pushDownSystem system (attrs.hydraJobs or { }) ret.hydraJobs)
|
}
|
||||||
else { ${system} = ret.${key}; };
|
|
||||||
in
|
|
||||||
attrs //
|
|
||||||
{
|
|
||||||
${key} = (attrs.${key} or { })
|
|
||||||
// (appendSystem key system ret);
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
builtins.foldl' op attrs (builtins.attrNames ret);
|
builtins.foldl' op attrs (builtins.attrNames ret);
|
||||||
|
|
Loading…
Add table
Reference in a new issue