Skip to content

Commit

Permalink
refactor(grow)!: merge ci' into ci as the distinction remained unused…
Browse files Browse the repository at this point in the history
… so far
  • Loading branch information
blaggacao committed Jun 3, 2023
1 parent 0ec387f commit 4b6973d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 71 deletions.
18 changes: 0 additions & 18 deletions grow/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@
{
ci = l.mapAttrsToList (_: set: set.ci) extracted;
}
# __std.ci'
{
ci' = l.mapAttrsToList (_: set: set.ci') extracted;
}
];
res = accumulate (l.map loadCellBlock cellBlocks');
in [
Expand All @@ -173,10 +169,6 @@
{
inherit (res) ci;
}
# __std.ci'
{
inherit (res) ci';
}
]; # };
res = accumulate (l.map loadCellFor cells');
in [
Expand All @@ -198,15 +190,6 @@
}
];
}
# __std.ci'
{
ci' = [
{
name = system;
value = res.ci';
}
];
}
];
res = accumulate (l.map loadOutputFor systems');
in
Expand All @@ -215,7 +198,6 @@
// {
__std.__schema = "v0";
__std.ci = l.listToAttrs res.ci;
__std.ci' = l.listToAttrs res.ci';
__std.init = l.listToAttrs res.init;
__std.actions = res.actions;
__std.cellsFrom = l.baseNameOf cellsFrom;
Expand Down
66 changes: 31 additions & 35 deletions grow/newExtractFor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,40 @@ This file implements an extractor that feeds the registry.
ci =
if cellBlock ? ci
then
l.mapAttrsToList (action: _:
if ! l.hasAttr action actions'
then
throw ''
divnix/std(ci-integration): Block Type '${cellBlock.type}' has no '${action}' Action defined.
---
${l.generators.toPretty {} (l.removeAttrs cellBlock ["__functor"])}
''
else {
inherit name;
cell = cellName;
block = cellBlock.name;
blockType = cellBlock.type;
inherit action;
})
l.mapAttrsToList (
action: _: let
action' = actions'.${action};
command = types.ActionCommand "Action \"${action'.name}\" of Cell Block \"${cellBlock.name}\" (Cell Block Type: \"${cellBlock.type}\")" action'.command;
in (
if ! l.hasAttr action actions'
then
throw ''
divnix/std(ci-integration): Block Type '${cellBlock.type}' has no '${action}' Action defined.
---
${l.generators.toPretty {} (l.removeAttrs cellBlock ["__functor"])}
''
else
{
inherit name;
cell = cellName;
block = cellBlock.name;
blockType = cellBlock.type;
inherit action;
targetDrv = command.targetDrv or target.drvPath or null; # can be null: nomad mainfests only hold data
actionDrv = command.drvPath;
}
// (
l.optionalAttrs (action' ? proviso) {inherit (action') proviso;}
)
// (
l.optionalAttrs (action' ? meta) {inherit (action') meta;}
)
)
)
cellBlock.ci
else [];

ci' = let
f = set: let
action' = actions'.${set.action};
action = types.ActionCommand "Action \"${action'.name}\" of Cell Block \"${cellBlock.name}\" (Cell Block Type: \"${cellBlock.type}\")" action'.command;
in
set
// {
targetDrv = action.targetDrv or target.drvPath or null; # can be null: nomad mainfests only hold data
actionDrv = action.drvPath;
}
// (
l.optionalAttrs (action' ? proviso) {inherit (action') proviso;}
)
// (
l.optionalAttrs (action' ? meta) {inherit (action') meta;}
);
in
map f ci;
in {
inherit ci ci';
inherit ci;
actions = l.mapAttrs (_: a: a.command) actions';
init =
targetTracer name
Expand Down
15 changes: 3 additions & 12 deletions grow/newHelpers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ This file implements aggregation helper for collecting blocks.
first = l.head new;
second = l.head cdr;
third = l.head cdr';
fourth = l.head cdr_;
tail = l.tail cdr_;
tail = l.tail cdr';

cdr = l.tail new;
cdr' = l.tail cdr;
cdr_ = l.tail cdr';
in
(
if first == null
Expand All @@ -31,23 +29,17 @@ This file implements aggregation helper for collecting blocks.
then {inherit (acc) init;}
else {init = acc.init ++ [third];}
)
// (
if fourth == null
then {inherit (acc) ci;}
else {ci = acc.ci ++ (l.concatMap (t: l.flatten t.ci) [fourth]);}
)
// (
if tail == [null]
then {inherit (acc) ci';}
else {ci' = acc.ci' ++ (l.concatMap (t: l.flatten t.ci') tail);}
then {inherit (acc) ci;}
else {ci = acc.ci ++ (l.concatMap (t: l.flatten t.ci) tail);}
)
)
{
output = {};
actions = {};
init = [];
ci = [];
ci' = []; # with drv (eval-costly)
};

optionalLoad = cond: elem:
Expand All @@ -58,6 +50,5 @@ This file implements aggregation helper for collecting blocks.
null # empty action
null # empty init
null # empty ci
null # empty ci'
];
}
6 changes: 0 additions & 6 deletions tests/_snapshots/grow
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@
x86_64-darwin = [ ];
x86_64-linux = [ ];
};
ci' = {
aarch64-darwin = [ ];
aarch64-linux = [ ];
x86_64-darwin = [ ];
x86_64-linux = [ ];
};
init = {
aarch64-darwin = [
{
Expand Down

0 comments on commit 4b6973d

Please sign in to comment.