-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.nix
152 lines (140 loc) · 4.19 KB
/
build.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
{ inputs, ... }:
{
perSystem =
{
config,
inputs',
system,
pkgs,
self',
...
}:
let
dataDir = "data";
data = [
{
name = "demo-plutarch-config.json";
path = config.packages.demo-plutarch-config;
}
{
name = "demo-plutustx-config.json";
path = config.packages.demo-plutustx-config;
}
];
rustFlake = inputs.flake-lang.lib."${system}".rustFlake {
inherit data;
src = ./.;
crateName = "demo";
exportTests = true;
nativeBuildInputs =
(pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.pkg-config
])
++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.gcc
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
]);
buildInputs = [
pkgs.openssl.dev
];
extraSources = [
# LB base schema and runtime libs
inputs'.lbf.packages.lbf-prelude-rust
inputs'.lbf.packages.lbf-plutus-rust
inputs'.lbf.packages.lbr-prelude-rust-src
inputs'.lbf.packages.lbr-prelude-derive-rust-src
# Demo API
config.packages.lbf-demo-config-api-rust
config.packages.lbf-demo-plutus-api-rust
];
devShellTools = [
self'.packages.pc-demo-rust-tests
];
devShellHook =
config.settings.shell.hook
+ ''
echo "LambdaBuffers for Rust testsuite"
echo ""
echo "Run pc-demo-rust-tests to execute the testsuite."
echo "or pc-demo-rust-tests up ogmios cardano_devnet -t to spin up an environment"
echo ""
'';
};
in
{
inherit (rustFlake) packages devShells;
checks =
let
data-drv = pkgs.linkFarm "data" data;
in
{
"demo-rust-checks" = pkgs.stdenv.mkDerivation {
name = "demo-rust-checks";
phases = [
"unpackPhase"
"checkPhase"
"buildPhase"
];
unpackPhase = ''
echo "Linking data"
ln -s ${./wallets} ./wallets
ln -s ${data-drv} ./${dataDir}
'';
checkPhase = ''
${self'.packages.pc-demo-rust-tests}/bin/pc-demo-rust-tests -t=false
'';
buildPhase = ''
mkdir $out
'';
doCheck = true;
};
};
cardano-devnet.initialFunds = {
"60a5587dc01541d4ad17d7a4416efee274d833f2fc894eef79976a3d06" = 9000000000;
};
process-compose.pc-demo-rust-tests = {
settings.processes = {
tests = {
command = "${self'.packages.demo-rust-test}/bin/run_tests.sh";
depends_on = {
cardano_devnet.condition = "process_healthy";
ogmios.condition = "process_healthy";
};
availability = {
exit_on_end = true;
exit_on_skipped = true;
};
};
cardano_devnet = {
command = config.packages.cardano-devnet;
readiness_probe = {
exec.command = ''
${inputs'.cardano-node.packages.cardano-cli}/bin/cardano-cli query tip \
--socket-path .devnet/node.socket \
--testnet-magic 42'';
initial_delay_seconds = 1;
period_seconds = 1;
};
};
ogmios = {
command = ''
${inputs'.ogmios.packages."ogmios:exe:ogmios"}/bin/ogmios \
--node-socket .devnet/node.socket \
--node-config .devnet/config.json
'';
readiness_probe = {
http_get = {
host = "127.0.0.1";
port = 1337;
path = "/health";
};
initial_delay_seconds = 2;
period_seconds = 2;
};
depends_on.cardano_devnet.condition = "process_healthy";
};
};
};
};
}