Skip to content

Commit a7f30c1

Browse files
committed
Make shell packages backend dependent
1 parent 2b58909 commit a7f30c1

File tree

11 files changed

+72
-39
lines changed

11 files changed

+72
-39
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ NUM_PROC = $(nproc --all)
1111
ERA ?= bage
1212

1313
PROFILE ?= default-${ERA}
14+
BACKEND ?= supervisor
1415
REV ?= master
1516
ITER ?=
1617
ARGS ?=
@@ -49,7 +50,7 @@ ci-targets: $(CI_TARGETS)
4950
## Base targets:
5051
##
5152
shell: ## Nix shell, (workbench from /nix/store), vars: PROFILE, CMD, RUN
52-
nix-shell -A 'workbench-shell' --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} ${ARGS} ${if ${CMD},--command "${CMD}"} ${if ${RUN},--run "${RUN}"}
53+
nix-shell -A 'workbench-shell' --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} --argstr backendName ${BACKEND} ${ARGS} ${if ${CMD},--command "${CMD}"} ${if ${RUN},--run "${RUN}"}
5354
shell-dev shell-prof shell-nix: shell
5455
shell-nix: ARGS += --arg 'workbenchDevMode' false ## Nix shell, (workbench from Nix store), vars: PROFILE, CMD, RUN
5556
shell-prof: ARGS += --arg 'profiled' true ## Nix shell, everything Haskell built profiled

nix/custom-config.nix

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ self: {
55
stateDir = "run/current";
66
batchName = "plain";
77
profileName = "default-bage";
8+
backendName = "supervisor";
89
basePort = 30000;
910
enableEKG = true;
1011
workbenchDevMode = true;

nix/pkgs.nix

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ final: prev: with final; {
109109
nomad-workbench-for-profile =
110110
{ batchName ? customConfig.localCluster.batchName
111111
, profileName ? customConfig.localCluster.profileName
112-
# FIXME: Makes no sense for this backend!
113112
, useCabalRun ? false
114113
, workbenchDevMode ? false
115114
, profiled ? false

nix/workbench/backend/nomad-run.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ in
126126
mv run/$run/* .
127127
rmdir run/$run run
128128
129-
130129
cat > $out/nix-support/hydra-build-products <<EOF
131130
report workbench-log $out wb-start.log
132131
report meta $out meta.json
@@ -144,6 +143,7 @@ in
144143
in
145144
{
146145
inherit stateDir;
146+
inherit profileName;
147147
inherit workbench nomad-workbench;
148148
inherit (nomad-workbench) backend;
149149
inherit profileNix profile topology genesis;

nix/workbench/backend/nomad.nix

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ let
1919
rec
2020
{ name = "nomad";
2121

22+
# Unlike the supervisor backend `useCabalRun` is always false here.
23+
useCabalRun = false;
24+
2225
services-config = import ./services-config.nix {inherit lib workbench basePort stateDir; useCabalRun = false; inherit enableEKG;};
2326

2427
extraShellPkgs = with pkgs; [

nix/workbench/backend/supervisor-run.nix

+2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ in
143143
in
144144
{
145145
inherit stateDir;
146+
inherit profileName;
146147
inherit workbench supervisord-workbench;
148+
inherit (supervisord-workbench) backend;
147149
inherit profileNix profile topology genesis;
148150
inherit interactive-start interactive-stop interactive-restart;
149151
inherit profile-run;

nix/workbench/backend/supervisor.nix

+21
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,29 @@ let
1919
rec
2020
{ name = "supervisor";
2121

22+
# Unlike the nomad backend `useCabalRun` is honored here.
23+
inherit useCabalRun;
24+
2225
services-config = import ./services-config.nix {inherit lib workbench basePort stateDir useCabalRun enableEKG;};
2326

27+
extraShellPkgs = with pkgs; [
28+
python3Packages.supervisor
29+
]
30+
++ lib.optionals ( useCabalRun)
31+
(with haskellPackages; [
32+
cabalWrapped
33+
ghcid
34+
haskellBuildUtils
35+
cabal-plan
36+
])
37+
## Workbench's main script is called directly in dev mode.
38+
++ lib.optionals (!useCabalRun)
39+
[
40+
cardano-node
41+
cardano-tracer
42+
tx-generator
43+
];
44+
2445
materialise-profile =
2546
{ profileNix }:
2647
pkgs.runCommand "workbench-backend-output-${profileNix.name}-${name}d"

nix/workbench/run.sh

+13-1
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ case "$op" in
309309
local usage="USAGE: wb run $op BATCH-NAME PROFILE-NAME [ENV-CONFIG-OPTS..] [-- BACKEND-ARGS-AND-ENV-CONFIG-OPTS..]"
310310
local batch=${1:?$usage}; shift
311311
local profile_name=${1:?$usage}; shift
312+
local backend_name=${1:?$usage}; shift
312313

313314
local profile= topology= genesis_cache_entry= manifest= preset= cabal_mode=
314315
while test $# -gt 0
@@ -360,7 +361,18 @@ case "$op" in
360361
profile describe-timing "$timing"
361362

362363
## 3. decide the tag:
363-
local run=$(jq '.start_tag' -r <<<$timing)$(if test "$batch" != 'plain'; then echo -n .$batch; fi).$hash.$profile_name$(test -z "$cabal_mode" && echo '.nix')
364+
if [ "$backend_name" == "supervisor" ];
365+
then
366+
local backend_identifier="sup"
367+
else
368+
if [ "$backend_name" == "nomad" ];
369+
then
370+
local backend_identifier="nom"
371+
else
372+
local backend_identifier="$backend_name"
373+
fi
374+
fi
375+
local run=$(jq '.start_tag' -r <<<$timing)$(if test "$batch" != 'plain'; then echo -n .$batch; fi).$hash.$profile_name.$backend_identifier
364376
progress "run | tag" "allocated run identifier (tag): $(with_color white $run)"
365377

366378
## 4. allocate directory:

nix/workbench/shell.nix

+16-32
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
##
88
, cardano-mainnet-mirror
99
##
10-
, profileName
10+
, workbenchRun
1111
, workbenchDevMode ? false
12-
, useCabalRun ? false
1312
##
1413
, profiled ? false
1514
, withHoogle ? true
@@ -18,18 +17,15 @@
1817

1918
with lib;
2019

21-
let cluster = pkgs.supervisord-workbench-for-profile {
22-
inherit profileName useCabalRun profiled;
23-
};
24-
25-
inherit (cluster) profile;
20+
let
21+
inherit (workbenchRun) profileName backend profile;
2622

27-
shellHook = { workbenchDevMode, useCabalRun, profiled, profileName, withMainnet }: ''
23+
shellHook = { profileName, backend, workbenchDevMode, profiled, withMainnet }: ''
2824
while test $# -gt 0
2925
do shift; done ## Flush argv[]
3026
31-
echo 'workbench shellHook: workbenchDevMode=${toString workbenchDevMode} useCabalRun=${toString useCabalRun} profiled=${toString profiled} profileName=${profileName}'
32-
export WB_BACKEND=supervisor
27+
echo 'workbench shellHook: profileName=${profileName} backendName=${backend.name} useCabalRun=${toString backend.useCabalRun} workbenchDevMode=${toString workbenchDevMode} profiled=${toString profiled} '
28+
export WB_BACKEND=${backend.name}
3329
export WB_SHELL_PROFILE=${profileName}
3430
export WB_SHELL_PROFILE_DIR=${profile}
3531
@@ -46,7 +42,7 @@ let cluster = pkgs.supervisord-workbench-for-profile {
4642
''}
4743
4844
${optionalString
49-
useCabalRun
45+
backend.useCabalRun
5046
''
5147
. nix/workbench/lib.sh
5248
. nix/workbench/lib-cabal.sh ${optionalString profiled "--profiled"}
@@ -74,7 +70,7 @@ let cluster = pkgs.supervisord-workbench-for-profile {
7470
in project.shellFor {
7571
name = "workbench-shell";
7672

77-
shellHook = shellHook { inherit workbenchDevMode useCabalRun profiled profileName withMainnet; };
73+
shellHook = shellHook { inherit profileName backend workbenchDevMode profiled withMainnet; };
7874

7975
inherit withHoogle;
8076

@@ -97,19 +93,14 @@ in project.shellFor {
9793
# These programs will be available inside the nix-shell.
9894
nativeBuildInputs = with pkgs; with haskellPackages; with cardanoNodePackages; [
9995
cardano-ping
100-
cabalWrapped
10196
db-analyser
102-
ghcid
103-
haskellBuildUtils
10497
pkgs.graphviz
10598
graphmod
106-
cabal-plan
10799
weeder
108100
nixWrapped
109101
pkgconfig
110102
profiteur
111103
profiterole
112-
python3Packages.supervisor
113104
ghc-prof-flamegraph
114105
sqlite-interactive
115106
tmux
@@ -118,24 +109,17 @@ in project.shellFor {
118109
pkgs.moreutils
119110
pkgs.pstree
120111
pkgs.time
121-
cluster.interactive-start
122-
cluster.interactive-stop
123-
cluster.interactive-restart
112+
workbenchRun.interactive-start
113+
workbenchRun.interactive-stop
114+
workbenchRun.interactive-restart
124115
] ++ lib.optional haveGlibcLocales pkgs.glibcLocales
125-
## Workbench's main script is called directly in dev mode.
126-
++ lib.optionals (!useCabalRun)
127-
[
128-
cardano-cli
129-
cardano-node
130-
cardano-topology
131-
cardano-tracer
132-
locli
133-
tx-generator
134-
]
116+
++ lib.optionals (!backend.useCabalRun) [cardano-topology cardano-cli locli]
117+
++ backend.extraShellPkgs
135118
++ lib.optionals (!workbenchDevMode)
136119
[
137-
cluster.workbench.workbench
138-
];
120+
workbenchRun.workbench.workbench
121+
]
122+
;
139123

140124
} // { inherit shellHook;
141125
}

nix/workbench/wb

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ start()
101101
{
102102
local batch_name=
103103
local profile_name= profile=
104-
local backend=supervisor
104+
local backend=${WB_BACKEND:-supervisor}
105105
local node_source=.
106106
local node_rev=
107107
local cabal_mode=
@@ -185,7 +185,7 @@ start()
185185
${run_allocate_args[@]}
186186
--manifest "$manifest"
187187
)
188-
run ${run_args[@]} 'allocate' $batch_name $profile_name "${args[@]}"
188+
run ${run_args[@]} 'allocate' $batch_name $profile_name $backend "${args[@]}"
189189
local run=$(run current-tag)
190190

191191
current_run_path=$(run current-path)

shell.nix

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ let defaultCustomConfig = import ./nix/custom-config.nix defaultCustomConfig;
44
in
55
{ withHoogle ? defaultCustomConfig.withHoogle
66
, profileName ? defaultCustomConfig.localCluster.profileName
7+
, backendName ? defaultCustomConfig.localCluster.backendName
78
, workbenchDevMode ? defaultCustomConfig.localCluster.workbenchDevMode
89
, useCabalRun ? true
910
, customConfig ? {
@@ -55,12 +56,21 @@ let
5556

5657
haveGlibcLocales = pkgs.glibcLocales != null && stdenv.hostPlatform.libc == "glibc";
5758

59+
workbenchRun =
60+
if backendName == "nomad"
61+
then pkgs.nomad-workbench-for-profile
62+
{ inherit profileName useCabalRun profiled; }
63+
# Supervidor by default.
64+
else pkgs.supervisord-workbench-for-profile
65+
{ inherit profileName useCabalRun profiled; }
66+
;
67+
5868
workbench-shell = with customConfig.localCluster;
5969
import ./nix/workbench/shell.nix
6070
{ inherit pkgs lib haskellLib project;
6171
inherit setLocale haveGlibcLocales commandHelp;
6272
inherit cardano-mainnet-mirror;
63-
inherit profileName workbenchDevMode useCabalRun;
73+
inherit workbenchRun workbenchDevMode;
6474
inherit profiled withHoogle;
6575
};
6676

0 commit comments

Comments
 (0)