Skip to content
Draft
32 changes: 14 additions & 18 deletions lib.mk
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

## proftgt :: target -> profile -> fullnixmode -> devmode -> autostart -> autostay -> profiled -> backend -> IO ()
## proftgt :: target -> profile -> fullnixmode -> devmode -> autostart -> autostay -> backend -> IO ()
define proftgt
$(1): shell
$(1): PROFILE = $(2)-${ERA}
$(1): BACKEND = $(8)
$(1): BACKEND = $(7)
ifeq ($(strip $(3)),true)
$(1): ARGS += --arg 'useCabalRun' false
endif
ifeq ($(strip $(4)),true)
$(1): ARGS += --arg 'workbenchDevMode' true
endif
ifeq ($(strip $(7)),true)
ifneq ($(strip $(WB_PROFILING)),)
$(1): ARGS += --arg 'profiling' '"$(WB_PROFILING)"'
else
$(1): ARGS += --arg 'profiling' '"none"'
Expand All @@ -30,22 +30,18 @@ endef

define define_profile_targets
ID ?= $(shell git symbolic-ref HEAD | sed 's_/_\n_g' | tail -n1)
## defining this target profname nix dev auto stay profiled backend
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false, false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-prof, $$(prof),false, true,false,false, true, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autoprof, $$(prof),false, true, true,false, true, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-profnix, $$(prof), true, true,false,false, true, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autoprofnix, $$(prof), true, true, true,false, true, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false, false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true, false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false, false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false, false, supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec, $$(prof), true,false,false,false, false, nomadexec)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec-auto, $$(prof), true,false, true,false, false, nomadexec)))
## defining this target profname nix dev auto stay backend
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false,supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false,supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true,supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false,supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false,supervisor)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec, $$(prof), true,false,false,false,nomadexec)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec-auto, $$(prof), true,false, true,false,nomadexec)))
endef

define define_profile_targets_nomadcloud
## defining this target profname nix dev auto stay profiled backend
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof), true,false,false,false, false, nomadcloud)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof), true,false, true,false, false, nomadcloud)))
## defining this target profname nix dev auto stay backend
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof), true,false,false,false,nomadcloud)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof), true,false, true,false,nomadcloud)))
endef
34 changes: 21 additions & 13 deletions nix/nixos/cardano-node-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -825,19 +825,27 @@ in {

profilingArgs = mkOption {
type = listOf str;
default = let commonProfilingArgs = ["--machine-readable" "-tcardano-node.stats" "-pocardano-node"]
++ optional (cfg.eventlog) "-l";
in if cfg.profiling == "time" then ["-p"] ++ commonProfilingArgs
else if cfg.profiling == "time-detail" then ["-P"] ++ commonProfilingArgs
else if cfg.profiling == "space" then ["-h"] ++ commonProfilingArgs
else if cfg.profiling == "space-cost" then ["-hc"] ++ commonProfilingArgs
else if cfg.profiling == "space-module" then ["-hm"] ++ commonProfilingArgs
else if cfg.profiling == "space-closure" then ["-hd"] ++ commonProfilingArgs
else if cfg.profiling == "space-type" then ["-hy"] ++ commonProfilingArgs
else if cfg.profiling == "space-retainer" then ["-hr"] ++ commonProfilingArgs
else if cfg.profiling == "space-bio" then ["-hb"] ++ commonProfilingArgs
else if cfg.profiling == "space-heap" then ["-hT"] ++ commonProfilingArgs
else [];
default =
[ "--machine-readable"
"-tcardano-node.stats"
"-pocardano-node"
]
++ optional (cfg.eventlog) "-l"
++ (
if cfg.profiling == "time" then ["-p"]
else if cfg.profiling == "time-detail" then ["-P"]
else if cfg.profiling == "space" then ["-h"]
else if cfg.profiling == "space-bio" then ["-hb"]
else if cfg.profiling == "space-closure" then ["-hd"]
else if cfg.profiling == "space-cost" then ["-hc"]
else if cfg.profiling == "space-heap" then ["-hT"]
else if cfg.profiling == "space-info" then ["-hi"]
else if cfg.profiling == "space-module" then ["-hm"]
else if cfg.profiling == "space-retainer" then ["-hr"]
else if cfg.profiling == "space-type" then ["-hy"]
else []
)
;
description = ''RTS profiling options'';
};

Expand Down
41 changes: 24 additions & 17 deletions nix/pkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,42 @@ let
inherit (final) pkgs;
inherit (prev.pkgs) lib;
inherit (prev) customConfig;

# A generic, fully parametric version of the workbench development environment.
# Parametrized helper entrypoint for the workbench development environment.
workbench = import ./workbench
{inherit pkgs lib; inherit (final) cardanoNodePackages cardanoNodeProject;};
{ inherit pkgs;
haskellProject = final.cardanoNodeProject;
}
;

# Workbench runner instantiated by parameters from customConfig:
in with final;
{
inherit (cardanoNodeProject.args) compiler-nix-name;

# To make it a flake output so it's available as input to external flakes.
inherit workbench;

# A workbench runner with default parameters from customConfig.
# Used in flake.nix for "workbench-ci-test" flake output package for CI.
workbench-runner =
{ profileName ? customConfig.localCluster.profileName
, profiling ? customConfig.profiling
, backendName ? customConfig.localCluster.backendName
, stateDir ? customConfig.localCluster.stateDir
, basePort ? customConfig.localCluster.basePort
, useCabalRun ? customConfig.localCluster.useCabalRun
, profiling ? customConfig.profiling
, batchName ? customConfig.localCluster.batchName
, workbenchStartArgs ? customConfig.localCluster.workbenchStartArgs
, cardano-node-rev ? null
}:
workbench.runner
{ inherit profileName profiling backendName stateDir basePort useCabalRun;
{ # To construct profile attrset with its `materialise-profile` function.
inherit profileName;
# To construct backend attrset with its `materialise-profile` function.
inherit backendName stateDir basePort useCabalRun profiling;
# Parameters for the workbench shell `start-cluster` command.
inherit batchName workbenchStartArgs cardano-node-rev;
};

in with final;
{
inherit (cardanoNodeProject.args) compiler-nix-name;

inherit workbench workbench-runner;
}
;

cabal = haskell-nix.cabal-install.${compiler-nix-name};

Expand Down Expand Up @@ -160,15 +169,13 @@ in with final;
value =
let
# Default values only ("run/current", 30000, profiling "none").
profile = workbench.profile {
inherit profileName;
profiling = "none";
};
profile = workbench.profile profileName;
backend = workbench.backend
{ backendName = "nomadcloud";
stateDir = customConfig.localCluster.stateDir;
basePort = customConfig.localCluster.basePort;
useCabalRun = customConfig.localCluster.useCabalRun;
profiling = "none";
}
;
profileBundle = profile.profileBundle
Expand Down
6 changes: 4 additions & 2 deletions nix/workbench/backend/nomad-job.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# To make it easier to improve and debug the almighty workbench!
################################################################################
{ pkgs
, lib
, stateDir
, profileBundle
, generatorTaskName
Expand All @@ -15,6 +14,8 @@

let

inherit (pkgs) lib;

profile = profileBundle.profile.value;

# Filesystem
Expand Down Expand Up @@ -737,8 +738,9 @@ let
destination = "local/${task_supervisord_conf}";
data = escapeTemplate (
import ./supervisor-conf.nix
{ inherit pkgs lib stateDir;
{ inherit pkgs stateDir;
inherit profile;
profiling = "none";
# Include only this taks' node
nodeSpecs = if taskName == "tracer"
then {}
Expand Down
28 changes: 17 additions & 11 deletions nix/workbench/backend/nomad.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{ pkgs
, lib
, haskellProject
, stateDir
, subBackendName
, ...
}:
let

inherit (pkgs) lib;

# Backend-specific Nix bits:
materialise-profile = { profileBundle }:
# Intermediate / workbench-adhoc container specifications
Expand Down Expand Up @@ -145,29 +147,33 @@ let
# the one used to enter the shell.
cardano-node = rec {
# Local reference only used if not "cloud".
# Avoid rebuilding on every commit because of `set-git-rev`.
nix-store-path = pkgs.cardanoNodePackages.cardano-node.passthru.noGitRev;
nix-store-path = haskellProject.exes.cardano-node;
flake-reference = "github:intersectmbo/cardano-node";
# Where to fetch the binary from during "cloud" runs.
# Avoid nix cache misses on every commit because of `set-git-rev`.
flake-output = "cardanoNodePackages.cardano-node.passthru.noGitRev"
;
};
cardano-cli = rec {
# Local reference only used if not "cloud".
# Avoid rebuilding on every commit because of `set-git-rev`.
nix-store-path = pkgs.cardanoNodePackages.cardano-cli.passthru.noGitRev;
nix-store-path = haskellProject.hsPkgs.cardano-cli.components.exes.cardano-cli;
flake-reference = "github:input-output-hk/cardano-cli";
# Where to fetch the binary from during "cloud" runs.
# Avoid nix cache misses on every commit because of `set-git-rev`.
flake-output = "cardanoNodePackages.cardano-cli.passthru.noGitRev";
};
cardano-tracer = rec {
# Local reference only used if not "cloud".
nix-store-path = pkgs.cardanoNodePackages.cardano-tracer;
nix-store-path = haskellProject.exes.cardano-tracer;
flake-reference = "github:intersectmbo/cardano-node";
flake-output = "cardanoNodePackages.cardano-tracer";
};
tx-generator = rec {
# Local reference only used if not "cloud".
nix-store-path = pkgs.cardanoNodePackages.tx-generator.passthru.noGitRev;
nix-store-path = haskellProject.exes.tx-generator;
flake-reference = "github:intersectmbo/cardano-node";
# Where to fetch the binary from during "cloud" runs.
# Avoid nix cache misses on every commit because of `set-git-rev`.
flake-output = "cardanoNodePackages.tx-generator.passthru.noGitRev";
};
}
Expand All @@ -187,15 +193,15 @@ let
exec = {
# TODO: oneTracerPerGroup
oneTracerPerCluster = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
{ inherit pkgs stateDir;
inherit profileBundle;
inherit generatorTaskName;
inherit installables;
oneTracerPerNode = false;
withSsh = false;
};
oneTracerPerNode = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
{ inherit pkgs stateDir;
inherit profileBundle;
inherit generatorTaskName;
inherit installables;
Expand All @@ -210,15 +216,15 @@ let
# Always "oneTracerPerNode"
# TODO: oneTracerPerCluster and oneTracerPerGroup
nomadExec = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
{ inherit pkgs stateDir;
inherit profileBundle;
inherit generatorTaskName;
inherit installables;
oneTracerPerNode = true;
withSsh = false;
};
ssh = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
{ inherit pkgs stateDir;
inherit profileBundle;
inherit generatorTaskName;
inherit installables;
Expand Down
24 changes: 17 additions & 7 deletions nix/workbench/backend/nomad/cloud.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{ pkgs
, lib
, haskellProject
, stateDir
, basePort # Ignored here and just returned to be used by `runner.nix`!
## `useCabalRun` not used here unlike `supervisor.nix`.
, basePort # ignored, just passed to the runner (unlike `supervisor.nix`).
## `useCabalRun` overridden parameter (unlike `supervisor.nix`).
## `profiling` overridden parameter (unlike `supervisor.nix`).
, ...
}:
let
Expand All @@ -12,9 +13,12 @@ let
# genesis files (Buckets needs write permissions for the deployer machine).
name = "nomadcloud";

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

# Unlike the supervisor backend `profiling` is always `"none"` here.
profiling = "none";

extraShellPkgs =
[
# SRE's patched Nomad 1.6.3 that enables `nix_installables` as artifacts.
Expand All @@ -35,7 +39,9 @@ let
# Build a Nomad Job specification for this Nomad "sub-backend".
materialise-profile =
let params = {
inherit pkgs lib stateDir;
inherit pkgs;
inherit haskellProject;
inherit stateDir;
subBackendName = "cloud";
};
in (import ../nomad.nix params).materialise-profile
Expand All @@ -58,7 +64,11 @@ in
inherit extraShellPkgs;
inherit materialise-profile;
inherit service-modules;
inherit stateDir basePort;
inherit stateDir;

# Returns something only to be compatible with what `runner.nix` expects.
inherit basePort;

inherit useCabalRun;
# Ignores the parameters and always returns `false` and `"none"`.
inherit useCabalRun profiling;
}
22 changes: 16 additions & 6 deletions nix/workbench/backend/nomad/exec.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{ pkgs
, lib
, haskellProject
, stateDir
, basePort # Ignored here and just returned to be used by `runner.nix`!
## `useCabalRun` not used here unlike `supervisor.nix`.
, basePort # ignored, just passed to the runner (unlike `supervisor.nix`).
## `useCabalRun` overridden parameter (unlike `supervisor.nix`).
## `profiling` overridden parameter (unlike `supervisor.nix`).
, ...
}:
let
Expand All @@ -15,6 +16,9 @@ let
# Unlike the supervisor backend `useCabalRun` is always false here.
useCabalRun = false;

# Unlike the supervisor backend `profiling` is always `"none"` here.
profiling = "none";

extraShellPkgs =
[
# SRE's patched Nomad 1.6.3 that enables `nix_installables` as artifacts.
Expand All @@ -33,7 +37,9 @@ let
# Build a Nomad Job specification for this Nomad "sub-backend".
materialise-profile =
let params = {
inherit pkgs lib stateDir;
inherit pkgs;
inherit haskellProject;
inherit stateDir;
subBackendName = "exec";
};
in (import ../nomad.nix params).materialise-profile
Expand All @@ -56,7 +62,11 @@ in
inherit extraShellPkgs;
inherit materialise-profile;
inherit service-modules;
inherit stateDir basePort;
inherit stateDir;

# Returns something only to be compatible with what `runner.nix` expects.
inherit basePort;

inherit useCabalRun;
# Ignores the parameters and always returns `false` and `"none"`.
inherit useCabalRun profiling;
}
Loading
Loading