Skip to content

Commit 255fc80

Browse files
committed
feat(pharos): add Pharos service configuration and module
1 parent 6c3aa34 commit 255fc80

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

modules/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
./random-alerts
88
./host-info.nix
99
./secrets.nix
10+
./pharos
1011
];
1112
}

modules/pharos/default.nix

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{ ... }:
2+
{
3+
flake.modules.nixos.pharos =
4+
{
5+
config,
6+
lib,
7+
pkgs,
8+
...
9+
}:
10+
let
11+
cfg = config.services.pharos;
12+
images = {
13+
"testnet" = {
14+
image = "public.ecr.aws/k2g7b7g1/pharos/testnet";
15+
tag = "63b85b6b";
16+
digest = "sha256:547a8519a11ab455871594580f7f5342863fb84d4a07c936969afe05f3aab358";
17+
sha256 = "sha256-WNCWeoQnT7TLmVQY+NuMtOXBtJ8TFlSNCekNWX90gDk=";
18+
};
19+
"devnet" = {
20+
image = "public.ecr.aws/k2g7b7g1/pharos";
21+
tag = "latest";
22+
digest = "sha256:82c7d84fc7d7f17056e947030c4a67bf23a139fe19539a6b237ab42df8215e7b";
23+
sha256 = "1lh9hna57y9n3h0lhmvy8grlg02caq6p1k9whgwp0av67wllk5km";
24+
};
25+
};
26+
in
27+
{
28+
options.services.pharos = with lib; {
29+
enable = mkEnableOption (lib.mdDoc "Pharos");
30+
network = mkOption {
31+
type = types.enum [
32+
"testnet"
33+
"devnet"
34+
"mainnet"
35+
];
36+
default = "testnet";
37+
description = "Network to connect to";
38+
};
39+
};
40+
config = {
41+
virtualisation.oci-containers.containers."pharos-${cfg.network}" = {
42+
# In order to get the hash and digest of the image, use:
43+
# nix run nixpkgs#nix-prefetch-docker -- --image-name 'public.ecr.aws/k2g7b7g1/pharos' --image-tag latest
44+
# The url can be found in the pharos documentation
45+
# https://docs.pharosnetwork.xyz/node-and-validator-guide/validator-node-deployment/using-docker-testnet
46+
# https://docs.pharosnetwork.xyz/node-and-validator-guide/validator-node-deployment/using-docker-devnet
47+
image = with images."${cfg.network}"; "${image}:${tag}";
48+
49+
imageFile =
50+
with images."${cfg.network}";
51+
pkgs.dockerTools.pullImage {
52+
imageName = image;
53+
imageDigest = digest;
54+
sha256 = sha256;
55+
finalImageName = image;
56+
finalImageTag = tag;
57+
};
58+
volumes = [
59+
"/var/lib/pharos-${cfg.network}:/data"
60+
];
61+
ports = [
62+
"18100:18100"
63+
"18200:18200"
64+
"19000:19000"
65+
];
66+
};
67+
assertions = [
68+
{
69+
assertion = cfg.network != "mainnet";
70+
message = "Pharos is not available on mainnet yet";
71+
}
72+
];
73+
systemd.tmpfiles.rules = [
74+
"d /var/lib/pharos-${cfg.network} 0700 root root - -"
75+
];
76+
};
77+
};
78+
}

0 commit comments

Comments
 (0)