Skip to content

Commit 038fff2

Browse files
deepfirefmaste
andcommitted
workbench: get rid of some unnecessary complications
Co-authored-by: Federico Mastellone <[email protected]>
1 parent d1ab502 commit 038fff2

12 files changed

+63
-90
lines changed

flake.nix

+5-7
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,9 @@
278278
benchmarks = collectComponents' "benchmarks" projectPackages;
279279
});
280280

281-
inherit (pkgs) workbench all-profiles-json supervisord-workbench-nix supervisord-workbench-for-profile;
281+
inherit (pkgs) workbench all-profiles-json workbench-instance;
282282

283283
packages =
284-
let
285-
supervisord-workbench =
286-
pkgs.callPackage supervisord-workbench-nix { workbench = pinned-workbench; };
287-
in
288284
exes
289285
# Linux only packages:
290286
// optionalAttrs (system == "x86_64-linux") rec {
@@ -296,10 +292,12 @@
296292

297293
## This is a very light profile, no caching&pinning needed.
298294
workbench-ci-test =
299-
(pkgs.supervisord-workbench-for-profile
295+
(pkgs.workbench-instance
300296
{
301-
# inherit supervisord-workbench; ## Not required, as long as it's fast.
302297
profileName = "ci-test-bage";
298+
backendName = "supervisor";
299+
## Not required, as long as it's fast.
300+
# workbench = pinned-workbench;
303301
cardano-node-rev =
304302
if __hasAttr "rev" self
305303
then self.rev

nix/custom-config.nix

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ self: {
77
profileName = "default-bage";
88
backendName = "supervisor";
99
basePort = 30000;
10-
enableEKG = true;
1110
workbenchDevMode = true;
1211
extraBackendConfig = {};
1312
};

nix/pkgs.nix

+24-30
Original file line numberDiff line numberDiff line change
@@ -79,45 +79,39 @@ final: prev: with final; {
7979
# A generic, parameteric version of the workbench development environment.
8080
workbench = pkgs.callPackage ./workbench {};
8181

82-
supervisord-workbench-cabal =
83-
{ workbench ? pkgs.workbench, ... }@args: pkgs.callPackage ./workbench/backend/supervisor.nix (args // { useCabalRun = true; });
84-
supervisord-workbench-nix =
85-
{ workbench ? pkgs.workbench, ... }@args: pkgs.callPackage ./workbench/backend/supervisor.nix args;
82+
all-profiles-json = (workbench.all-profiles
83+
{ inherit (workbench-instance { backendName = "supervisor";
84+
profileName = "default-bage";
85+
}) backend; }).JSON;
8686

87-
nomad-workbench =
88-
{ workbench ? pkgs.workbench, ... }@args: pkgs.callPackage ./workbench/backend/nomad.nix (args // { inherit nix2container; });
89-
90-
all-profiles-json = (workbench.all-profiles{ inherit (supervisord-workbench-nix) backend; }).JSON;
91-
92-
# An instance of the workbench, specialised to the supervisord backend and a profile,
93-
# that can be used with nix-shell or lorri.
87+
# A parametrisable workbench, that can be used with nix-shell or lorri.
9488
# See https://input-output-hk.github.io/haskell.nix/user-guide/development/
95-
supervisord-workbench-for-profile =
96-
{ batchName ? customConfig.localCluster.batchName
97-
, profileName ? customConfig.localCluster.profileName
98-
, useCabalRun ? false
99-
, workbenchDevMode ? false
100-
, profiled ? false
101-
, supervisord-workbench ? pkgs.callPackage ./workbench/backend/supervisor.nix { inherit useCabalRun; }
102-
, cardano-node-rev ? null
103-
}:
104-
pkgs.callPackage ./workbench/backend/supervisor-run.nix
105-
{
106-
inherit batchName profileName supervisord-workbench cardano-node-rev;
107-
};
108-
109-
nomad-workbench-for-profile =
110-
{ batchName ? customConfig.localCluster.batchName
89+
workbench-instance =
90+
let backendRegistry =
91+
{
92+
supervisor = {
93+
backend-workbench = ./workbench/backend/supervisor.nix;
94+
workbench-runner = ./workbench/backend/supervisor-run.nix;
95+
};
96+
nomad = {
97+
backend-workbench = ./workbench/backend/nomad.nix;
98+
workbench-runner = ./workbench/backend/nomad-run.nix;
99+
};
100+
};
101+
in
102+
{ backendName
111103
, profileName ? customConfig.localCluster.profileName
104+
, batchName ? customConfig.localCluster.batchName
112105
, useCabalRun ? false
113106
, workbenchDevMode ? false
114107
, profiled ? false
115-
, nomad-workbench ? pkgs.callPackage ./workbench/backend/nomad.nix { inherit nix2container; }
108+
, workbench ? pkgs.workbench
109+
, backendWorkbench ? pkgs.callPackage (backendRegistry."${backendName}".backend-workbench) { inherit useCabalRun workbench; }
116110
, cardano-node-rev ? null
117111
}:
118-
pkgs.callPackage ./workbench/backend/nomad-run.nix
112+
pkgs.callPackage (backendRegistry."${backendName}".workbench-runner)
119113
{
120-
inherit batchName profileName nomad-workbench cardano-node-rev;
114+
inherit batchName profileName backendWorkbench cardano-node-rev;
121115
};
122116

123117
# Disable failing python uvloop tests

nix/workbench/backend/nomad-conf.nix

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
# Cardano packages/executables.
33
, cardano-node, cardano-tracer, tx-generator
44
# OCI Image builder.
5-
, nix2container
65
}:
76

87
let
98

109
# Why `nix2container` instead of the built-in `dockerTools` ?:
1110
# - https://lewo.abesis.fr/posts/nix-build-container-image/
1211
# - https://discourse.nixos.org/t/nix2container-another-dockertools-buildimage-implementation-based-on-skopeo/21688
13-
n2c = nix2container.outputs.packages.x86_64-linux.nix2container;
12+
n2c = pkgs.nix2container.outputs.packages.x86_64-linux.nix2container;
1413

1514
clusterImage = n2c.buildImage {
1615
name = "registry.workbench.iog.io/cluster";

nix/workbench/backend/nomad-run.nix

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
let
2+
backendName = "nomad";
23
batchNameDefault = "plain";
34
profileNameDefault = "default-bage";
45
in
56
{ pkgs
67
, cardanoNodePackages
7-
, nomad-workbench
8+
, backendWorkbench
89
##
910
, profileName ? profileNameDefault
1011
, batchName ? batchNameDefault
@@ -13,14 +14,14 @@ in
1314
, cardano-node-rev ? "0000000000000000000000000000000000000000"
1415
}:
1516
let
16-
inherit (nomad-workbench) workbench backend cacheDir stateDir basePort;
17+
inherit (backendWorkbench) workbench backend cacheDir stateDir basePort;
1718

18-
with-nomad-profile =
19+
with-backend-profile =
1920
{ envArgsOverride ? {} }: ## TODO: envArgsOverride is not used!
2021
workbench.with-profile
2122
{ inherit backend profileName; };
2223

23-
inherit (with-nomad-profile {}) profileNix profile topology genesis;
24+
inherit (with-backend-profile {}) profileNix profile topology genesis;
2425
in
2526
let
2627

@@ -70,11 +71,11 @@ in
7071
{ trace ? false }:
7172
let
7273
inherit
73-
(with-nomad-profile
74+
(with-backend-profile
7475
{ envArgsOverride = { cacheDir = "./cache"; stateDir = "./"; }; })
7576
profileNix profile topology genesis;
7677

77-
run = pkgs.runCommand "workbench-run-nomad-${profileName}"
78+
run = pkgs.runCommand "workbench-run-${backendName}-${profileName}"
7879
{ requiredSystemFeatures = [ "benchmark" ];
7980
nativeBuildInputs = with cardanoNodePackages; with pkgs; [
8081
bash
@@ -95,7 +96,7 @@ in
9596
cd $out
9697
export HOME=$out
9798
98-
export WB_BACKEND=nomad
99+
export WB_BACKEND=${backendName}
99100
export CARDANO_NODE_SOCKET_PATH=$(wb backend get-node-socket-path ${stateDir} node-0)
100101
101102
cmd=(
@@ -144,8 +145,8 @@ in
144145
{
145146
inherit stateDir;
146147
inherit profileName;
147-
inherit workbench nomad-workbench;
148-
inherit (nomad-workbench) backend;
148+
inherit workbench backendWorkbench;
149+
inherit (backendWorkbench) backend;
149150
inherit profileNix profile topology genesis;
150151
inherit interactive-start interactive-stop interactive-restart;
151152
inherit profile-run;

nix/workbench/backend/nomad.nix

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ let
44
stateDir = "run/current";
55
in
66
{ pkgs
7-
, lib, nix2container
7+
, lib
88
, workbench
99
##
1010
, cacheDir ? cacheDirDefault
1111
, extraBackendConfig ? {}
1212
## `useCabalRun` not used here like in `supervisor.nix`.
13-
, enableEKG ? true
14-
##
1513
, ...
1614
}:
1715
let
@@ -22,7 +20,7 @@ let
2220
# Unlike the supervisor backend `useCabalRun` is always false here.
2321
useCabalRun = false;
2422

25-
services-config = import ./services-config.nix {inherit lib workbench basePort stateDir; useCabalRun = false; inherit enableEKG;};
23+
services-config = import ./services-config.nix {inherit lib workbench basePort stateDir; useCabalRun = false;};
2624

2725
extraShellPkgs = with pkgs; [
2826
# https://docs.podman.io/en/latest/markdown/podman.1.html#rootless-mode
@@ -52,7 +50,6 @@ let
5250
inherit
5351
(pkgs.cardanoNodePackages)
5452
cardano-node cardano-tracer tx-generator;
55-
inherit nix2container;
5653
};
5754
in pkgs.runCommand "workbench-backend-output-${profileNix.name}-${name}"
5855
(rec {

nix/workbench/backend/services-config.nix

-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
, basePort ? 30000
55
, stateDir ? "run/current"
66
, useCabalRun ? false
7-
, enableEKG ? true
87
}:
98
with lib;
109
{
@@ -68,16 +67,6 @@ with lib;
6867
ShelleyGenesisFile = "./genesis/genesis-shelley.json";
6968
ByronGenesisFile = "./genesis/byron/genesis.json";
7069
}
71-
// optionalAttrs enableEKG
72-
(let portShiftEkg = 100;
73-
portShiftPrometheus = 200;
74-
in {
75-
hasEKG = port + portShiftEkg;
76-
hasPrometheus = ["127.0.0.1" (port + portShiftPrometheus)];
77-
setupBackends = [
78-
"EKGViewBK"
79-
];
80-
})
8170
);
8271

8372
finaliseNodeArgs =

nix/workbench/backend/supervisor-run.nix

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
let
2+
backendName = "supervisor";
23
batchNameDefault = "plain";
34
profileNameDefault = "default-bage";
45
in
56
{ pkgs
67
, cardanoNodePackages
7-
, supervisord-workbench
8+
, backendWorkbench
89
##
910
, profileName ? profileNameDefault
1011
, batchName ? batchNameDefault
@@ -13,14 +14,14 @@ in
1314
, cardano-node-rev ? "0000000000000000000000000000000000000000"
1415
}:
1516
let
16-
inherit (supervisord-workbench) workbench backend cacheDir stateDir basePort;
17+
inherit (backendWorkbench) workbench backend cacheDir stateDir basePort;
1718

18-
with-supervisord-profile =
19+
with-backend-profile =
1920
{ envArgsOverride ? {} }: ## TODO: envArgsOverride is not used!
2021
workbench.with-profile
2122
{ inherit backend profileName; };
2223

23-
inherit (with-supervisord-profile {}) profileNix profile topology genesis;
24+
inherit (with-backend-profile {}) profileNix profile topology genesis;
2425
in
2526
let
2627

@@ -70,11 +71,11 @@ in
7071
{ trace ? false }:
7172
let
7273
inherit
73-
(with-supervisord-profile
74+
(with-backend-profile
7475
{ envArgsOverride = { cacheDir = "./cache"; stateDir = "./"; }; })
7576
profileNix profile topology genesis;
7677

77-
run = pkgs.runCommand "workbench-run-supervisord-${profileName}"
78+
run = pkgs.runCommand "workbench-run-${backendName}-${profileName}"
7879
{ requiredSystemFeatures = [ "benchmark" ];
7980
nativeBuildInputs = with cardanoNodePackages; with pkgs; [
8081
bash
@@ -95,7 +96,7 @@ in
9596
cd $out
9697
export HOME=$out
9798
98-
export WB_BACKEND=supervisor
99+
export WB_BACKEND=${backendName}
99100
export CARDANO_NODE_SOCKET_PATH=$(wb backend get-node-socket-path ${stateDir} node-0)
100101
101102
cmd=(
@@ -144,8 +145,8 @@ in
144145
{
145146
inherit stateDir;
146147
inherit profileName;
147-
inherit workbench supervisord-workbench;
148-
inherit (supervisord-workbench) backend;
148+
inherit workbench backendWorkbench;
149+
inherit (backendWorkbench) backend;
149150
inherit profileNix profile topology genesis;
150151
inherit interactive-start interactive-stop interactive-restart;
151152
inherit profile-run;

nix/workbench/backend/supervisor.nix

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ in
1010
, cacheDir ? cacheDirDefault
1111
, extraBackendConfig ? {}
1212
, useCabalRun ? false
13-
, enableEKG ? true
1413
##
1514
, ...
1615
}:
@@ -22,7 +21,7 @@ let
2221
# Unlike the nomad backend `useCabalRun` is honored here.
2322
inherit useCabalRun;
2423

25-
services-config = import ./services-config.nix {inherit lib workbench basePort stateDir useCabalRun enableEKG;};
24+
services-config = import ./services-config.nix {inherit lib workbench basePort stateDir useCabalRun;};
2625

2726
extraShellPkgs = with pkgs; [
2827
python3Packages.supervisor

nix/workbench/profiles/prof0-defaults.jq

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def era_defaults($era):
7575
, shutdown_on_slot_synced: null
7676
, shutdown_on_block_synced: null
7777
, tracing_backend: "trace-dispatcher" ## or "iohk-monitoring"
78+
, ekg: false
7879
, tracer: true
7980
, verbatim:
8081
{

nix/workbench/tests/default.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{ pkgs
22
}: let
3-
inherit (pkgs) supervisord-workbench-for-profile cardano-cli cardanolib-py cardano-node;
3+
inherit (pkgs) workbench-instance cardano-cli cardanolib-py cardano-node;
44
stateDir = "./state-cluster-test";
55
# We want a really short duration for tests
6-
cluster' = supervisord-workbench-for-profile {
6+
cluster' = workbench-instance {
77
genesisParams = {
88
slotLength = 0.1;
99
decentralisationParam = 0.8;

shell.nix

+7-12
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,25 @@ let
5757
haveGlibcLocales = pkgs.glibcLocales != null && stdenv.hostPlatform.libc == "glibc";
5858

5959
workbench-shell =
60-
let
61-
workbenchRun =
62-
if backendName == "nomad"
63-
then pkgs.nomad-workbench-for-profile
64-
{ inherit profileName useCabalRun profiled; }
65-
# Supervidor by default.
66-
else pkgs.supervisord-workbench-for-profile
67-
{ inherit profileName useCabalRun profiled; }
68-
;
69-
in with customConfig.localCluster;
60+
with customConfig.localCluster;
7061
import ./nix/workbench/shell.nix
7162
{ inherit pkgs lib haskellLib project;
7263
inherit setLocale haveGlibcLocales commandHelp;
7364
inherit cardano-mainnet-mirror;
74-
inherit workbenchRun workbenchDevMode;
65+
inherit workbenchDevMode;
7566
inherit profiled withHoogle;
67+
workbenchRun =
68+
pkgs.workbench-instance
69+
{ inherit backendName profileName useCabalRun profiled; };
7670
};
7771

7872
devops =
7973
let profileName = "devops-bage";
80-
workbenchRun = pkgs.supervisord-workbench-for-profile
74+
workbenchRun = pkgs.workbench-instance
8175
{
8276
inherit profileName;
8377
useCabalRun = false;
78+
backendName = "supervisor";
8479
};
8580
devopsShellParams =
8681
{ inherit profileName;

0 commit comments

Comments
 (0)