/
nomad.nix
163 lines (160 loc) · 6.5 KB
/
nomad.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{ pkgs
, lib
, stateDir
# TODO: Fetch this from config services inside materialise-profile !
, eventlogged ? true
, ...
}:
let
validateNodeSpecs = { nodeSpecsValue }:
true
;
# Backend-specific Nix bits:
materialise-profile =
{ profileData }:
let
# Intermediate / workbench-adhoc container specifications
containerSpecs = rec {
#
diretories = rec {
work = "/local";
state = stateDir;
run = lib.strings.concatStringsSep "/" [ work state ];
};
# The actual commit.
gitrev = pkgs.gitrev;
# Binaries.
containerPkgs = {
bashInteractive = rec {
nix-store-path = pkgs.bashInteractive;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.bashInteractive";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
coreutils = rec {
nix-store-path = pkgs.coreutils;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.coreutils";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
findutils = rec {
nix-store-path = pkgs.findutils;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.findutils";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
gnutar = rec {
nix-store-path = pkgs.gnutar;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.gnutar";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
zstd = rec {
nix-store-path = pkgs.zstd;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.zstd";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
wget = rec {
nix-store-path = pkgs.wget;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.wget";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
supervisor = rec {
nix-store-path = pkgs.python3Packages.supervisor;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.python3Packages.supervisor";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
# TODO: profileData.node-services."node-0".serviceConfig.value.eventlog
# builtins.trace (builtins.attrNames profileData.node-services."node-0".serviceConfig.value.eventlog) XXXX
cardano-node = rec {
nix-store-path = with pkgs;
if eventlogged
then cardanoNodePackages.cardano-node.passthru.eventlogged
else cardanoNodePackages.cardano-node
;
flake-reference = "github:input-output-hk/cardano-node";
flake-output =
if eventlogged
then "cardanoNodePackages.cardano-node.passthru.eventlogged"
else "cardanoNodePackages.cardano-node"
;
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
cardano-tracer = rec {
nix-store-path = pkgs.cardanoNodePackages.cardano-tracer;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "cardanoNodePackages.cardano-tracer";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
tx-generator = rec {
nix-store-path = pkgs.cardanoNodePackages.tx-generator;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "cardanoNodePackages.tx-generator";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
};
supervisord = {
url = "unix:///tmp/supervisor.sock";
conf = lib.strings.concatStringsSep "/"
[ diretories.run "supervisor" "supervisord.conf"]
;
};
ociImage = import ./oci-images.nix
{ inherit pkgs lib;
inherit containerPkgs;
}
;
nomadJob = {
podman = {
# TODO: oneTracerPerGroup
oneTracerPerCluster = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
inherit profileData;
inherit containerSpecs;
# May evolve to a "cloud" flag!
execTaskDriver = false;
oneTracerPerNode = false;
};
oneTracerPerNode = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
inherit profileData;
inherit containerSpecs;
# May evolve to a "cloud" flag!
execTaskDriver = false;
oneTracerPerNode = true;
};
};
exec = {
# TODO: oneTracerPerGroup
oneTracerPerCluster = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
inherit profileData;
inherit containerSpecs;
# May evolve to a "cloud" flag!
execTaskDriver = true;
oneTracerPerNode = false;
};
oneTracerPerNode = import ./nomad-job.nix
{ inherit pkgs lib stateDir;
inherit profileData;
inherit containerSpecs;
# May evolve to a "cloud" flag!
execTaskDriver = true;
oneTracerPerNode = true;
};
};
};
};
in pkgs.runCommand "workbench-backend-output-${profileData.profileName}-nomad"
({
containerSpecsJSON = pkgs.writeText "workbench-cluster-container-pkgs.json"
(lib.generators.toJSON {} containerSpecs);
})
''
mkdir $out
ln -s $containerSpecsJSON $out/container-specs.json
'';
in { inherit materialise-profile; }