Skip to content

Commit

Permalink
wb | pass a workbench as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaste committed Sep 13, 2024
1 parent 49e6fef commit 94fae6b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 34 deletions.
2 changes: 0 additions & 2 deletions nix/pkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ let
, workbenchStartArgs ? customConfig.localCluster.workbenchStartArgs
, profiling ? customConfig.profiling
, cardano-node-rev ? null
, workbench ? pkgs.workbench
}:
workbench.runner
{
inherit stateDir batchName profileName backendName basePort useCabalRun;
inherit workbenchDevMode workbenchStartArgs profiling cardano-node-rev;
inherit workbench;
};

in with final;
Expand Down
46 changes: 23 additions & 23 deletions nix/workbench/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,30 @@ let
${pkgs.jq}/bin/jq '${query}' "''${args[@]}" > $out
'';

run-analysis = import ./analyse/analyse.nix;

in pkgs.lib.fix (self: {
inherit workbench' workbench runWorkbench;
inherit runJq;

inherit run-analysis;

inherit
(import ./profile/profile.nix
{ inherit pkgs lib;
inherit (cardanoNodePackages) cardanoLib;
workbench = self;
}
)
profile-names-json
profile-names
materialise-profile;

# A conveniently-parametrisable workbench preset.
# See https://input-output-hk.github.io/haskell.nix/user-guide/development/
# The general idea is:
# 1. backendName -> stateDir -> basePort -> useCabalRun -> backend
# 2. batchName -> profileName -> profiling -> backend -> workbench -> runner
# * `workbench` is in case a pinned version of the workbench is needed.
# 2. batchName -> profileName -> profiling -> backend -> runner
runner =
let backendRegistry = {
nomadcloud = params:
Expand All @@ -96,7 +114,6 @@ let
, workbenchStartArgs
, profiling
, cardano-node-rev
, workbench
}:
let backend =
# The `useCabalRun` flag is set in the backend to allow the backend to
Expand All @@ -110,24 +127,7 @@ let
inherit pkgs lib cardanoNodePackages;
inherit batchName profileName backend;
inherit cardano-node-rev;
inherit workbench workbenchDevMode workbenchStartArgs profiling;
workbench = self;
inherit workbenchDevMode workbenchStartArgs profiling;
};

run-analysis = import ./analyse/analyse.nix;

in {
inherit workbench' workbench runWorkbench;
inherit runJq;

inherit runner;

inherit run-analysis;

inherit
(import ./profile/profile.nix
{inherit pkgs lib runJq runWorkbench; inherit (cardanoNodePackages) cardanoLib;}
)
profile-names-json
profile-names
materialise-profile;
}
})
14 changes: 7 additions & 7 deletions nix/workbench/profile/profile.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{ pkgs, lib, cardanoLib
, runJq
, runWorkbench
, workbench
}:

let
mkProfileJson = { profileName }:
runWorkbench "profile-${profileName}.json"
workbench.runWorkbench "profile-${profileName}.json"
"profile json ${profileName}";

mkTopologyFiles = { profileName, profileJson }:
Expand All @@ -21,7 +20,7 @@ let
;

mkNodeSpecsJson = { profileName, profileJson }:
runWorkbench "node-specs-${profileName}.json"
workbench.runWorkbench "node-specs-${profileName}.json"
"profile node-specs ${profileName} ${mkTopologyFiles {inherit profileName profileJson;}}";

mkGenesisFiles = { profileName, profileJson, nodeSpecsJson }:
Expand Down Expand Up @@ -63,7 +62,7 @@ let
''
;

jsonFilePretty = name: x: runJq name ''--null-input --sort-keys
jsonFilePretty = name: x: workbench.runJq name ''--null-input --sort-keys
--argjson x '${x}'
'' "$x";

Expand All @@ -75,7 +74,8 @@ let
{
inherit backend profile nodeSpecs;
inherit topologyFiles profiling;
inherit runWorkbench jsonFilePretty;
inherit workbench;
inherit jsonFilePretty;
baseNodeConfig = cardanoLib.environments.testnet.nodeConfig;
})
node-services;
Expand Down Expand Up @@ -115,7 +115,7 @@ let
};

profile-names-json =
runWorkbench "profile-names.json" "profiles list";
workbench.runWorkbench "profile-names.json" "profiles list";

profile-names =
__fromJSON (__readFile profile-names-json);
Expand Down
4 changes: 2 additions & 2 deletions nix/workbench/service/nodes.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ pkgs
, runWorkbench
, workbench
, jsonFilePretty

## The cardano-node config used as baseline:
Expand Down Expand Up @@ -220,7 +220,7 @@ let

topology =
rec {
JSON = runWorkbench
JSON = workbench.runWorkbench
"topology-${name}.json"
"topology projection-for local-${nodeSpec.kind} ${toString i} ${profileName} ${topologyFiles} ${toString backend.basePort}";
value = __fromJSON (__readFile JSON);
Expand Down

0 comments on commit 94fae6b

Please sign in to comment.