Skip to content

Commit

Permalink
Merge with 'Make shell packages backend dependent'
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaste committed Nov 11, 2022
1 parent dbf4a93 commit ba4cbf5
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion nix/workbench/backend/nomad-run.nix
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ in
mv run/$run/* .
rmdir run/$run run
cat > $out/nix-support/hydra-build-products <<EOF
report workbench-log $out wb-start.log
report meta $out meta.json
Expand All @@ -144,6 +143,7 @@ in
in
{
inherit stateDir;
inherit profileName;
inherit workbench nomad-workbench;
inherit (nomad-workbench) backend;
inherit profileNix profile topology genesis;
Expand Down
1 change: 1 addition & 0 deletions nix/workbench/backend/nomad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let
rec
{ name = "nomad";

# Unlike the supervisor backend `useCabalRun` is always false here.
useCabalRun = false;

services-config = import ./services-config.nix {inherit lib workbench basePort stateDir; useCabalRun = false; inherit enableEKG;};
Expand Down
1 change: 1 addition & 0 deletions nix/workbench/backend/supervisor-run.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ in
in
{
inherit stateDir;
inherit profileName;
inherit workbench supervisord-workbench;
inherit (supervisord-workbench) backend;
inherit profileNix profile topology genesis;
Expand Down
1 change: 1 addition & 0 deletions nix/workbench/backend/supervisor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let
rec
{ name = "supervisor";

# Unlike the nomad backend `useCabalRun` is honored here.
inherit useCabalRun;

services-config = import ./services-config.nix {inherit lib workbench basePort stateDir useCabalRun enableEKG;};
Expand Down
14 changes: 13 additions & 1 deletion nix/workbench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ case "$op" in
local usage="USAGE: wb run $op BATCH-NAME PROFILE-NAME [ENV-CONFIG-OPTS..] [-- BACKEND-ARGS-AND-ENV-CONFIG-OPTS..]"
local batch=${1:?$usage}; shift
local profile_name=${1:?$usage}; shift
local backend_name=${1:?$usage}; shift

local profile= topology= genesis_cache_entry= manifest= preset= cabal_mode=
while test $# -gt 0
Expand Down Expand Up @@ -315,7 +316,18 @@ case "$op" in
profile describe-timing "$timing"

## 3. decide the tag:
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')
if [ "$backend_name" == "supervisor" ];
then
local backend_identifier="sup"
else
if [ "$backend_name" == "nomad" ];
then
local backend_identifier="nom"
else
local backend_identifier="$backend_name"
fi
fi
local run=$(jq '.start_tag' -r <<<$timing)$(if test "$batch" != 'plain'; then echo -n .$batch; fi).$hash.$profile_name.$backend_identifier
progress "run | tag" "allocated run identifier (tag): $(with_color white $run)"

## 4. allocate directory:
Expand Down
23 changes: 7 additions & 16 deletions nix/workbench/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
##
, cardano-mainnet-mirror
##
, profileName
, backendName
, useCabalRun ? false
, workbenchRun
, workbenchDevMode ? false
##
, profiled ? false
Expand All @@ -19,15 +17,8 @@

with lib;

let cluster =
if backendName == "nomad"
then pkgs.nomad-workbench-for-profile
{ inherit profileName useCabalRun profiled; }
else pkgs.supervisord-workbench-for-profile
{ inherit profileName useCabalRun profiled; }
;

inherit (cluster) backend profile;
let
inherit (workbenchRun) profileName backend profile;

shellHook = { profileName, backend, workbenchDevMode, profiled, withMainnet }: ''
while test $# -gt 0
Expand Down Expand Up @@ -118,15 +109,15 @@ in project.shellFor {
pkgs.moreutils
pkgs.pstree
pkgs.time
cluster.interactive-start
cluster.interactive-stop
cluster.interactive-restart
workbenchRun.interactive-start
workbenchRun.interactive-stop
workbenchRun.interactive-restart
] ++ lib.optional haveGlibcLocales pkgs.glibcLocales
++ lib.optionals (!backend.useCabalRun) [cardano-topology cardano-cli locli]
++ backend.extraShellPkgs
++ lib.optionals (!workbenchDevMode)
[
cluster.workbench.workbench
workbenchRun.workbench.workbench
]
;

Expand Down
2 changes: 1 addition & 1 deletion nix/workbench/wb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ start()
${run_allocate_args[@]}
--manifest "$manifest"
)
run ${run_args[@]} 'allocate' $batch_name $profile_name "${args[@]}"
run ${run_args[@]} 'allocate' $batch_name $profile_name $backend "${args[@]}"
local run=$(run current-tag)

current_run_path=$(run current-path)
Expand Down
11 changes: 10 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,21 @@ let

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

workbenchRun =
if backendName == "nomad"
then pkgs.nomad-workbench-for-profile
{ inherit profileName useCabalRun profiled; }
# Supervidor by default.
else pkgs.supervisord-workbench-for-profile
{ inherit profileName useCabalRun profiled; }
;

workbench-shell = with customConfig.localCluster;
import ./nix/workbench/shell.nix
{ inherit pkgs lib haskellLib project;
inherit setLocale haveGlibcLocales commandHelp;
inherit cardano-mainnet-mirror;
inherit profileName backendName useCabalRun workbenchDevMode;
inherit workbenchRun workbenchDevMode;
inherit profiled withHoogle;
};

Expand Down

0 comments on commit ba4cbf5

Please sign in to comment.