Skip to content

Commit 862cdad

Browse files
committed
wb | make workbench outputs git rev independent
1 parent 3257162 commit 862cdad

File tree

12 files changed

+1062
-1076
lines changed

12 files changed

+1062
-1076
lines changed

flake.nix

+16-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,22 @@
131131
# Add some executables from other relevant packages
132132
inherit (bech32.components.exes) bech32;
133133
inherit (ouroboros-consensus-cardano.components.exes) db-analyser db-synthesizer db-truncater;
134-
# Add cardano-node and cardano-cli with their git revision stamp
135-
cardano-node = set-git-rev project.exes.cardano-node;
136-
cardano-cli = set-git-rev cardano-cli.components.exes.cardano-cli;
134+
# Add cardano-node and cardano-cli with their git revision stamp.
135+
# Keep available an alternative without the git revision, like the other
136+
# passthru (profiled, asserted and eventlogged in nix/haskell.nix) that
137+
# have no git revision but for the same compilation alternative.
138+
cardano-node =
139+
let node = project.exes.cardano-node;
140+
in lib.recursiveUpdate
141+
(set-git-rev node)
142+
{passthru = {noGitRev = node;};}
143+
;
144+
cardano-cli =
145+
let cli = cardano-cli.components.exes.cardano-cli;
146+
in lib.recursiveUpdate
147+
(set-git-rev cli)
148+
{passthru = {noGitRev = cli;};}
149+
;
137150
});
138151

139152
mkCardanoNodePackages = project:

nix/haskell.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ project.appendOverlays (with haskellLib.projectOverlays; [
428428
(name: { configureFlags = [ "--ghc-option=-eventlog" ]; });
429429
})];
430430
};
431-
# add passthru and gitrev to hsPkgs:
431+
# add passthru to hsPkgs:
432432
hsPkgs = lib.mapAttrsRecursiveCond (v: !(lib.isDerivation v))
433433
(path: value:
434434
if (lib.isAttrs value) then

nix/workbench/backend/nomad-job.nix

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
, stateDir
99
, profileBundle
1010
, generatorTaskName
11-
, containerPkgs
11+
, installables
1212
, oneTracerPerNode ? false
1313
, withSsh ? false
1414
}:
@@ -75,8 +75,8 @@ let
7575

7676
entrypoint =
7777
let
78-
coreutils = containerPkgs.coreutils.nix-store-path;
79-
supervisor = containerPkgs.supervisor.nix-store-path;
78+
coreutils = installables.coreutils.nix-store-path;
79+
supervisor = installables.supervisor.nix-store-path;
8080
in escapeTemplate
8181
''
8282
# Store entrypoint's envars and "uname" in a file for debugging purposes.
@@ -510,7 +510,7 @@ let
510510
# ERROR: cannot verify iog-cardano-perf.s3.eu-central-1.amazonaws.com's certificate, issued by 'CN=Amazon RSA 2048 M01,O=Amazon,C=US':
511511
# Unable to locally verify the issuer's authority.
512512
# To connect to iog-cardano-perf.s3.eu-central-1.amazonaws.com insecurely, use `--no-check-certificate'.
513-
SSL_CERT_FILE = "${containerPkgs.cacert.nix-store-path}/etc/ssl/certs/ca-bundle.crt";
513+
SSL_CERT_FILE = "${installables.cacert.nix-store-path}/etc/ssl/certs/ca-bundle.crt";
514514
};
515515

516516
# Sensible defaults.
@@ -946,9 +946,9 @@ let
946946
../service/ssh.nix
947947
{
948948
inherit pkgs;
949-
bashInteractive = containerPkgs.bashInteractive.nix-store-path;
950-
coreutils = containerPkgs.coreutils.nix-store-path;
951-
sshdExecutable = "${containerPkgs.openssh_hacks.nix-store-path}/bin/sshd";
949+
bashInteractive = installables.bashInteractive.nix-store-path;
950+
coreutils = installables.coreutils.nix-store-path;
951+
sshdExecutable = "${installables.openssh_hacks.nix-store-path}/bin/sshd";
952952
}
953953
;
954954
in [
@@ -1002,12 +1002,12 @@ let
10021002
{
10031003
driver = "exec";
10041004
config = {
1005-
command = "${containerPkgs.bashInteractive.nix-store-path}/bin/bash";
1005+
command = "${installables.bashInteractive.nix-store-path}/bin/bash";
10061006
args = ["local/entrypoint.sh"];
10071007
nix_installables =
10081008
(lib.attrsets.mapAttrsToList
1009-
(name: attr: attr.installable)
1010-
containerPkgs
1009+
(name: attr: attr.nix-store-path)
1010+
installables
10111011
)
10121012
;
10131013
};

nix/workbench/backend/nomad.nix

+86-119
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ let
1313
# Intermediate / workbench-adhoc container specifications
1414
let containerSpecs = rec {
1515
##########################################################################
16-
# The actual commit. The one used when entering the workbench.
17-
gitrev = pkgs.gitrev;
1816
# Where to deploy inside the Task, needed to send commands (`nomad exec`).
1917
diretories = rec {
2018
work = "/local";
@@ -29,9 +27,9 @@ let
2927
;
3028
};
3129
# Binaries. Flake references to the local nix store or remote repos.
32-
containerPkgs = installables {inherit gitrev;};
30+
containerPkgs = installables;
3331
# The Nomad Job description for the requested sub-backend.
34-
nomadJob = nomad-job {inherit profileBundle containerPkgs;};
32+
nomadJob = nomad-job {inherit profileBundle installables;};
3533
##########################################################################
3634
};
3735
in pkgs.runCommand "workbench-backend-data-${profileBundle.profile.value.name}-nomad"
@@ -45,101 +43,81 @@ let
4543
''
4644
;
4745

48-
# The installables are all the Nix packages that will be avaiable inside the
49-
# Nomad Task. This dependencies are defined inside the Nomad Job as strings
50-
# that can be either a path to the local nix store or a flake reference to
51-
# fetch from some repo.
52-
# In the case of cloud deployment the "installable" must always reference
53-
# a commit accesible from every Nomad client machine and for local / "exec"
54-
# the "nix-store-path" property is used to allow to run with local changes.
55-
# The workbench will by default insert in the Nomad Job description the
56-
# "installable" property as defined here while keeping the extra details as a
57-
# `jq` friendly reference that are used to change it later.
58-
installables = {gitrev}:
59-
############################################################################
60-
# The "default" / basic environment where the node will run. ###############
61-
# This pkgs rarely change and are almost always cached. ###############
62-
############################################################################
63-
(lib.attrsets.mapAttrs
64-
(name: attr:
65-
# The installable property is always the same.
66-
let flakeReference = attr.flake-reference;
67-
flakeOutput = attr.flake-output;
68-
# The commit must come from `pkgs` because all script are using
69-
# this for the shebang and other basic tools ("coreutils") and are
70-
# also the dependencies used inside the workbench, like `jq`.
71-
commit = pkgs.gitrev;
72-
in attr // {installable="${flakeReference}/${commit}#${flakeOutput}";}
73-
)
74-
{
75-
coreutils = {
76-
nix-store-path = pkgs.coreutils;
77-
flake-reference = "github:intersectmbo/cardano-node";
78-
flake-output = "legacyPackages.x86_64-linux.coreutils";
79-
installable = null;
80-
};
81-
bashInteractive = {
82-
nix-store-path = pkgs.bashInteractive;
83-
flake-reference = "github:intersectmbo/cardano-node";
84-
flake-output = "legacyPackages.x86_64-linux.bashInteractive";
85-
installable = null;
86-
};
87-
findutils = {
88-
nix-store-path = pkgs.findutils;
89-
flake-reference = "github:intersectmbo/cardano-node";
90-
flake-output = "legacyPackages.x86_64-linux.findutils";
91-
installable = null;
92-
};
93-
iputils = {
94-
nix-store-path = pkgs.iputils;
95-
flake-reference = "github:intersectmbo/cardano-node";
96-
flake-output = "legacyPackages.x86_64-linux.iputils";
97-
installable = null;
98-
};
99-
gnutar = {
100-
nix-store-path = pkgs.gnutar;
101-
flake-reference = "github:intersectmbo/cardano-node";
102-
flake-output = "legacyPackages.x86_64-linux.gnutar";
103-
installable = null;
104-
};
105-
zstd = {
106-
nix-store-path = pkgs.zstd;
107-
flake-reference = "github:intersectmbo/cardano-node";
108-
flake-output = "legacyPackages.x86_64-linux.zstd";
109-
installable = null;
110-
};
111-
wget = {
112-
nix-store-path = pkgs.wget;
113-
flake-reference = "github:intersectmbo/cardano-node";
114-
flake-output = "legacyPackages.x86_64-linux.wget";
115-
installable = null;
116-
};
117-
cacert = {
118-
nix-store-path = pkgs.cacert;
119-
flake-reference = "github:intersectmbo/cardano-node";
120-
flake-output = "legacyPackages.x86_64-linux.cacert";
121-
installable = null;
122-
};
123-
supervisor = {
124-
nix-store-path = pkgs.python3Packages.supervisor;
125-
flake-reference = "github:intersectmbo/cardano-node";
126-
flake-output = "legacyPackages.x86_64-linux.python3Packages.supervisor";
127-
installable = null;
128-
};
129-
gnugrep = {
130-
nix-store-path = pkgs.gnugrep;
131-
flake-reference = "github:intersectmbo/cardano-node";
132-
flake-output = "legacyPackages.x86_64-linux.gnugrep";
133-
installable = null;
134-
};
135-
jq = {
136-
nix-store-path = pkgs.jq;
137-
flake-reference = "github:intersectmbo/cardano-node";
138-
flake-output = "legacyPackages.x86_64-linux.jq";
139-
installable = null;
140-
};
141-
}
142-
)
46+
# The installables are all the Nix packages that are needed inside the Nomad
47+
# Task. These dependencies are defined inside the Nomad Job as strings that
48+
# can either be a path to the local nix store or a flake reference to fetch
49+
# from a repo.
50+
# In the case of cloud deployment the installables must always reference a
51+
# commit accessible from every Nomad client machine, for local / "exec" the
52+
# "nix-store-path" property is used for simplicity.
53+
# The workbench will by default insert in the Nomad Job description the local
54+
# path of this packages while keeping the extra details as a `jq` friendly
55+
# reference that are used to change it later appending the desired commit
56+
# (interchanging commits it's still an untested feature).
57+
# For cloud runs references:
58+
# installable="${flakeReference}/${commit}#${flakeOutput}"
59+
installables =
60+
{
61+
############################################################################
62+
# The "default" / basic environment where the node will run. ###############
63+
# This pkgs rarely change and are almost always cached. ###############
64+
############################################################################
65+
coreutils = {
66+
nix-store-path = pkgs.coreutils;
67+
flake-reference = "github:intersectmbo/cardano-node";
68+
flake-output = "legacyPackages.x86_64-linux.coreutils";
69+
};
70+
bashInteractive = {
71+
nix-store-path = pkgs.bashInteractive;
72+
flake-reference = "github:intersectmbo/cardano-node";
73+
flake-output = "legacyPackages.x86_64-linux.bashInteractive";
74+
};
75+
findutils = {
76+
nix-store-path = pkgs.findutils;
77+
flake-reference = "github:intersectmbo/cardano-node";
78+
flake-output = "legacyPackages.x86_64-linux.findutils";
79+
};
80+
iputils = {
81+
nix-store-path = pkgs.iputils;
82+
flake-reference = "github:intersectmbo/cardano-node";
83+
flake-output = "legacyPackages.x86_64-linux.iputils";
84+
};
85+
gnutar = {
86+
nix-store-path = pkgs.gnutar;
87+
flake-reference = "github:intersectmbo/cardano-node";
88+
flake-output = "legacyPackages.x86_64-linux.gnutar";
89+
};
90+
zstd = {
91+
nix-store-path = pkgs.zstd;
92+
flake-reference = "github:intersectmbo/cardano-node";
93+
flake-output = "legacyPackages.x86_64-linux.zstd";
94+
};
95+
wget = {
96+
nix-store-path = pkgs.wget;
97+
flake-reference = "github:intersectmbo/cardano-node";
98+
flake-output = "legacyPackages.x86_64-linux.wget";
99+
};
100+
cacert = {
101+
nix-store-path = pkgs.cacert;
102+
flake-reference = "github:intersectmbo/cardano-node";
103+
flake-output = "legacyPackages.x86_64-linux.cacert";
104+
};
105+
supervisor = {
106+
nix-store-path = pkgs.python3Packages.supervisor;
107+
flake-reference = "github:intersectmbo/cardano-node";
108+
flake-output = "legacyPackages.x86_64-linux.python3Packages.supervisor";
109+
};
110+
gnugrep = {
111+
nix-store-path = pkgs.gnugrep;
112+
flake-reference = "github:intersectmbo/cardano-node";
113+
flake-output = "legacyPackages.x86_64-linux.gnugrep";
114+
};
115+
jq = {
116+
nix-store-path = pkgs.jq;
117+
flake-reference = "github:intersectmbo/cardano-node";
118+
flake-output = "legacyPackages.x86_64-linux.jq";
119+
};
120+
}
143121
//
144122
############################################################################
145123
# Optional container enabled OpenSSH to properly fetch ~1TB cloud logs. ####
@@ -157,8 +135,6 @@ let
157135
nix-store-path = pkgs.rsync; # Not used locally.
158136
flake-reference = "github:intersectmbo/cardano-node";
159137
flake-output = "legacyPackages.x86_64-linux.rsync";
160-
# Same commit as the basic packages.
161-
installable = "${flake-reference}/${pkgs.gitrev}#${flake-output}";
162138
};
163139
}
164140
//
@@ -172,49 +148,40 @@ let
172148
cardano-node = rec {
173149
# Local reference only used if not "cloud".
174150
nix-store-path = with pkgs;
175-
# TODO: - cardano-node.passthru.profiled
176-
# - cardano-node.passthru.eventlogged
177-
# - cardano-node.passthru.asserted
178-
# profileBundle.node-services."node-0".serviceConfig.value.eventlog
179-
# builtins.trace (builtins.attrNames profileBundle.node-services."node-0".serviceConfig.value.eventlog) XXXX
180151
if eventlogged
181152
then cardanoNodePackages.cardano-node.passthru.eventlogged
182-
else cardanoNodePackages.cardano-node
153+
else cardanoNodePackages.cardano-node.passthru.noGitRev
183154
;
184155
flake-reference = "github:intersectmbo/cardano-node";
185156
flake-output =
186157
if eventlogged
187158
then "cardanoNodePackages.cardano-node.passthru.eventlogged"
188-
else "cardanoNodePackages.cardano-node"
159+
else "cardanoNodePackages.cardano-node.passthru.noGitRev"
189160
;
190-
installable = "${flake-reference}/${gitrev}#${flake-output}";
191161
};
192162
cardano-cli = rec {
193163
# Local reference only used if not "cloud".
194-
nix-store-path = pkgs.cardanoNodePackages.cardano-cli;
164+
nix-store-path = pkgs.cardanoNodePackages.cardano-cli.passthru.noGitRev;
195165
flake-reference = "github:input-output-hk/cardano-cli";
196-
flake-output = "cardanoNodePackages.cardano-cli";
197-
installable = "${flake-reference}/${gitrev}#${flake-output}";
166+
flake-output = "cardanoNodePackages.cardano-cli.passthru.noGitRev";
198167
};
199168
cardano-tracer = rec {
200169
# Local reference only used if not "cloud".
201170
nix-store-path = pkgs.cardanoNodePackages.cardano-tracer;
202171
flake-reference = "github:intersectmbo/cardano-node";
203172
flake-output = "cardanoNodePackages.cardano-tracer";
204-
installable = "${flake-reference}/${gitrev}#${flake-output}";
205173
};
206174
tx-generator = rec {
207175
# Local reference only used if not "cloud".
208176
nix-store-path = pkgs.cardanoNodePackages.tx-generator;
209177
flake-reference = "github:intersectmbo/cardano-node";
210178
flake-output = "cardanoNodePackages.tx-generator";
211-
installable = "${flake-reference}/${gitrev}#${flake-output}";
212179
};
213180
}
214181
;
215182

216183
# The "exec" or "cloud" Nomad Job description.
217-
nomad-job = {profileBundle, containerPkgs}:
184+
nomad-job = {profileBundle, installables}:
218185
# TODO: Repeated code, add the generator's node name to profile.json
219186
let generatorTaskName = if builtins.hasAttr "explorer" profileBundle.node-specs.value
220187
then "explorer"
@@ -230,15 +197,15 @@ let
230197
{ inherit pkgs lib stateDir;
231198
inherit profileBundle;
232199
inherit generatorTaskName;
233-
inherit containerPkgs;
200+
inherit installables;
234201
oneTracerPerNode = false;
235202
withSsh = false;
236203
};
237204
oneTracerPerNode = import ./nomad-job.nix
238205
{ inherit pkgs lib stateDir;
239206
inherit profileBundle;
240207
inherit generatorTaskName;
241-
inherit containerPkgs;
208+
inherit installables;
242209
oneTracerPerNode = true;
243210
withSsh = false;
244211
};
@@ -253,15 +220,15 @@ let
253220
{ inherit pkgs lib stateDir;
254221
inherit profileBundle;
255222
inherit generatorTaskName;
256-
inherit containerPkgs;
223+
inherit installables;
257224
oneTracerPerNode = true;
258225
withSsh = false;
259226
};
260227
ssh = import ./nomad-job.nix
261228
{ inherit pkgs lib stateDir;
262229
inherit profileBundle;
263230
inherit generatorTaskName;
264-
inherit containerPkgs;
231+
inherit installables;
265232
oneTracerPerNode = true;
266233
withSsh = true;
267234
};

0 commit comments

Comments
 (0)