Skip to content

Commit

Permalink
workbench: add a -profnix flavour, for Nix-supplied profiled binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Apr 6, 2023
1 parent 12e373d commit b1d6449
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
30 changes: 16 additions & 14 deletions lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ endif
endef

define define_profile_targets
$$(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)-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)-nomad, $$(prof), true,false,false,false,false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomad-auto, $$(prof), true,false, true,false,false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman, $$(prof), true,false,false,false,false, nomadpodman)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman-auto, $$(prof), true,false, true,false,false, nomadpodman)))
$$(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)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nixops, $$(prof), true, true,false,false,false, nixops)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonixops, $$(prof), true, true, true, true,false, nixops)))
## 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)-profnix, $$(prof), true, true,false,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)-nomad, $$(prof), true,false,false,false, false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomad-auto, $$(prof), true,false, true,false, false, nomad)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman, $$(prof), true,false,false,false, false, nomadpodman)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman-auto, $$(prof), true,false, true,false, false, nomadpodman)))
$$(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)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nixops, $$(prof), true, true,false,false, false, nixops)))
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonixops, $$(prof), true, true, true, true, false, nixops)))
endef
2 changes: 1 addition & 1 deletion nix/pkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let
inherit pkgs lib cardanoNodePackages;
inherit batchName profileName backend;
inherit cardano-node-rev;
inherit workbench workbenchDevMode;
inherit workbench workbenchDevMode profiled;
};

# Workbench instantiated by parameters from customConfig:
Expand Down
7 changes: 4 additions & 3 deletions nix/workbench/backend/runner.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
, profileName
, backend
##
, cardano-node-rev ? "0000000000000000000000000000000000000000"
, cardano-node-rev
, workbench
, workbenchDevMode ? false
, workbenchDevMode
, profiled
##
, cacheDir ? "${__getEnv "HOME"}/.cache/cardano-workbench"
}:
Expand All @@ -18,7 +19,7 @@ let
inherit (backend) stateDir basePort useCabalRun;

profileNix = workbench.materialise-profile
{ inherit profileName backend; };
{ inherit profileName backend profiled; };
backendNix = backend.materialise-profile
{ inherit profileNix; };
in
Expand Down
12 changes: 6 additions & 6 deletions nix/workbench/profile/profile.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ rec {
import ../genesis/genesis.nix
{ inherit pkgs profileName profileJson nodeSpecsJson; };

services = { profile, nodeSpecs, topologyFiles, backend }:
services = { profile, nodeSpecs, topologyFiles, backend, profiled }:
rec {
inherit
(pkgs.callPackage
../service/nodes.nix
{
inherit backend profile;
inherit backend profile profiled;
inherit runJq runWorkbench nodeSpecs topologyFiles;
baseNodeConfig = cardanoLib.environments.testnet.nodeConfig;
})
Expand All @@ -54,7 +54,7 @@ rec {
};

## WARNING: IFD !!
profile = { profileName, backend }:
profile = { profileName, backend, profiled }:
rec {
inherit profileName;

Expand Down Expand Up @@ -82,7 +82,7 @@ rec {

inherit (services
{
inherit backend;
inherit backend profiled;
profile = value;
nodeSpecs = node-specs.value;
topologyFiles = topology.files;
Expand Down Expand Up @@ -147,11 +147,11 @@ rec {

materialise-profile =
# `workbench` is the pinned workbench in case there is one.
{ profileName, backend }:
profileArgs@{ profileName, ... }:
let
mkProfileData = profileName:
profileData {
profile = profile { inherit profileName backend; };
profile = profile profileArgs;
};
ps = lib.genAttrs profile-names mkProfileData;
in
Expand Down
9 changes: 6 additions & 3 deletions nix/workbench/service/nodes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

, backend
, profile
, profiled
, nodeSpecs
, topologyFiles
}:
Expand Down Expand Up @@ -226,11 +227,13 @@ let
};
in
finaliseNodeService profile nodeSpec
((if profiled
then { profiling = "time"; }
else { eventlog = mkForce true; })
//
{
inherit port;

eventlog = mkForce true;

## For the definition of 'nodeConfigBits', please see above.
## Meaning:
## 1. take the common base
Expand Down Expand Up @@ -263,7 +266,7 @@ let
]
else []
);
};
});

## Given an env config, evaluate it and produce the node service.
## Call the given function on this service.
Expand Down

0 comments on commit b1d6449

Please sign in to comment.