This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathdefault.nix
145 lines (117 loc) · 6.08 KB
/
default.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
# Build the cardano node image
#
# Several examples for pkgs.dockerTools are here
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/docker/examples.nix
#
{
# Pinned packages with Niv
sources ? import ../../sources.nix,
haskellNix ? import sources.haskellNix {},
nixpkgsSrc ? haskellNix.sources.nixpkgs-2105,
nixpkgsArgs ? haskellNix.nixpkgsArgs,
pkgs ? import nixpkgsSrc nixpkgsArgs,
# Required image architecture
imageArch,
# Required version args
cardanoVersion,
cardanoRev,
debianVersion,
cabalVersion,
ghcVersion,
glvVersion,
# https://hydra.iohk.io/build/12179730/download/1/index.html
hydraBuild ? "12179730",
baseImage ? import ../baseImage { inherit debianVersion; },
cardano ? import ../../cardano { inherit cardanoVersion cardanoRev cabalVersion ghcVersion; },
gLiveView ? import ../../gLiveView { inherit glvVersion; },
libsodium ? import ../../libsodium {},
}:
let
imageName = "nessusio/cardano-node";
# curl -o "./nix/docker/node/context/config/mainnet-config.json" "https://hydra.iohk.io/build/${hydraBuild}/download/1/mainnet-config.json"
# curl -o "./nix/docker/node/context/config/testnet-config.json" "https://hydra.iohk.io/build/${hydraBuild}/download/1/testnet-config.json"
# The mainet configs for the cardano-node
mainnet-config = ./context/config/mainnet-config.json;
mainnet-topology = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/mainnet-topology.json";
mainnet-byron-genesis = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/mainnet-byron-genesis.json";
mainnet-shelley-genesis = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/mainnet-shelley-genesis.json";
mainnet-alonzo-genesis = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/mainnet-alonzo-genesis.json";
# The testnet configs for the cardano-node
testnet-config = ./context/config/testnet-config.json;
testnet-topology = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/testnet-topology.json";
testnet-byron-genesis = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/testnet-byron-genesis.json";
testnet-shelley-genesis = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/testnet-shelley-genesis.json";
testnet-alonzo-genesis = builtins.fetchurl "https://hydra.iohk.io/build/${hydraBuild}/download/1/testnet-alonzo-genesis.json";
# Custom mainnet-config.json
# The Docker context with static content
context = ./context;
in
pkgs.dockerTools.buildImage {
name = imageName;
tag = "${cardanoVersion}${cardanoRev}-${imageArch}";
fromImage = "${baseImage.out}/nessusio-debian.tgz";
contents = [
# Base packages needed by cardano
pkgs.bashInteractive # Provide the BASH shell
pkgs.cacert # X.509 certificates of public CA's
pkgs.coreutils # Basic utilities expected in GNU OS's
pkgs.curl # CLI tool for transferring files via URLs
pkgs.glibcLocales # Locale information for the GNU C Library
pkgs.iana-etc # IANA protocol and port number assignments
pkgs.iproute # Utilities for controlling TCP/IP networking
pkgs.iputils # Useful utilities for Linux networking
pkgs.socat # Utility for bidirectional data transfer
pkgs.utillinux # System utilities for Linux
libsodium # Cardano crypto library fork
# Packages needed on RaspberryPi
pkgs.numactl # Tools for non-uniform memory access
# Packages needed by gLiveView
pkgs.bc # An arbitrary precision calculator
pkgs.gawk # GNU implementation of the Awk programming language
pkgs.gnugrep # GNU implementation of the Unix grep command
pkgs.jq # Utility for JSON processing
pkgs.ncurses # Free software emulation of curses
pkgs.netcat # Networking utility for reading from and writing to network connections
pkgs.procps # Utilities that give information about processes using the /proc filesystem
pkgs.tuptime # Total uptime & downtime statistics utility
];
# Set creation date to build time. Breaks reproducibility
created = "now";
# Requires 'system-features = kvm' in /etc/nix/nix.conf
# https://discourse.nixos.org/t/cannot-build-docker-image/7445
# runAsRoot = '' do root stuff '';
extraCommands = ''
mkdir -p usr/local/bin
mkdir -p opt/cardano/config
mkdir -p opt/cardano/data
mkdir -p opt/cardano/ipc
mkdir -p opt/cardano/logs
# Entrypoint and helper scripts
cp ${context}/bin/* usr/local/bin
# Node configurations
cp ${mainnet-config} opt/cardano/config/mainnet-config.json
cp ${mainnet-topology} opt/cardano/config/mainnet-topology.json
cp ${mainnet-byron-genesis} opt/cardano/config/mainnet-byron-genesis.json
cp ${mainnet-shelley-genesis} opt/cardano/config/mainnet-shelley-genesis.json
cp ${mainnet-alonzo-genesis} opt/cardano/config/mainnet-alonzo-genesis.json
cp ${testnet-config} opt/cardano/config/testnet-config.json
cp ${testnet-topology} opt/cardano/config/testnet-topology.json
cp ${testnet-byron-genesis} opt/cardano/config/testnet-byron-genesis.json
cp ${testnet-shelley-genesis} opt/cardano/config/testnet-shelley-genesis.json
cp ${testnet-alonzo-genesis} opt/cardano/config/testnet-alonzo-genesis.json
# gLiveView scripts
cp -r ${gLiveView}/cnode-helper-scripts cnode-helper-scripts
# Create links for executables
ln -s ${cardano}/bin/cardano-cli usr/local/bin/cardano-cli
ln -s ${cardano}/bin/cardano-node usr/local/bin/cardano-node
ln -s ${cardano}/bin/cardano-submit-api usr/local/bin/cardano-submit-api
'';
config = {
Env = [
# Export the default socket path for use by the cli
"CARDANO_NODE_SOCKET_PATH=/opt/cardano/ipc/node.socket"
];
Entrypoint = [ "entrypoint" ];
StopSignal = "SIGINT";
};
}