Skip to content

Commit 8668bed

Browse files
committed
feat(machines): add machine per nixos module
1 parent 98f73f6 commit 8668bed

17 files changed

+272
-0
lines changed

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
./checks
222222
./modules
223223
./packages
224+
./machines
224225
./shells
225226
];
226227
systems = [

machines/blankpass.txt

Whitespace-only changes.

machines/default.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
lib,
3+
self,
4+
...
5+
}:
6+
let
7+
system = "x86_64-linux";
8+
mkMachine = x: {
9+
"${lib.removeSuffix ".nix" x}" = lib.nixosSystem {
10+
specialArgs = { inherit self system; };
11+
modules = lib.unique [
12+
./modules/base.nix
13+
./modules/${x}
14+
];
15+
};
16+
};
17+
in
18+
{
19+
flake.nixosConfigurations = (
20+
lib.mergeAttrsList (lib.map (x: mkMachine x) (builtins.attrNames (builtins.readDir ./modules)))
21+
);
22+
}

machines/modules/all.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
self,
3+
lib,
4+
system,
5+
...
6+
}:
7+
{
8+
imports = lib.map (x: ./. + "/${x}") (
9+
builtins.attrNames (
10+
lib.removeAttrs (builtins.readDir ./.) [
11+
"base.nix"
12+
"all.nix"
13+
]
14+
)
15+
);
16+
17+
environment.systemPackages = lib.attrValues self.packages."${system}";
18+
}

machines/modules/base.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{ system, lib, ... }:
2+
{
3+
nixpkgs.system = system;
4+
fileSystems = {
5+
"/".device = lib.mkDefault "/dev/sda";
6+
};
7+
boot.loader.grub.devices = lib.mkDefault [ "/dev/sda" ];
8+
virtualisation.vmVariant = {
9+
virtualization = {
10+
diskSize = 10 * 1024 * 1024 * 1024; # 10GB
11+
memorySize = 8192; # 8GB
12+
cores = 4;
13+
};
14+
};
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{ self, ... }:
2+
{
3+
imports = [
4+
self.modules.nixos.ethereum-validators-monitoring
5+
];
6+
7+
services.ethereum-validators-monitoring = {
8+
db = {
9+
host = "http://localhost:8123/";
10+
user = "ethereum";
11+
password-file = ../blankpass.txt;
12+
name = "ethereum";
13+
};
14+
instances = {
15+
# The Ethereum Validator Monitoring sends out too many requests to servers,
16+
# which causes attestations to be missing. Therefore, as we lack a
17+
# dedicated server, we are unable to have e-v-m.
18+
};
19+
};
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{ self, ... }:
2+
{
3+
imports = [
4+
self.modules.nixos.folder-size-metrics
5+
];
6+
7+
services.folder-size-metrics = {
8+
enable = true;
9+
# args = { #Unchanged
10+
# port = 8888;
11+
# base-path = "/var/lib";
12+
# interval-sec = 60;
13+
# };
14+
};
15+
}

machines/modules/healthcheck.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{ self, pkgs, ... }:
2+
{
3+
imports = [
4+
self.modules.nixos.healthcheck
5+
];
6+
7+
systemd.services.test = {
8+
description = "";
9+
enable = true;
10+
path = with pkgs; [
11+
];
12+
serviceConfig = {
13+
Type = "oneshot";
14+
Restart = "on-failure";
15+
RestartSec = "10s";
16+
17+
ExecStart = ''
18+
sleep 10; # Simulate a startup delay.
19+
echo "Starting test service...";
20+
echo "Test" > /tmp/test.log
21+
while true ; do
22+
echo "Test" | nc -l 8080
23+
done
24+
'';
25+
};
26+
};
27+
28+
# --- Health Check Configuration ---
29+
mcl.services.test.healthcheck = {
30+
runtimePackages = with pkgs; [
31+
netcat
32+
curl
33+
];
34+
35+
# READINESS: Use the notify pattern to signal when the service is truly ready.
36+
readiness-probe = {
37+
enable = true;
38+
command = "ls /tmp/test.log";
39+
interval = 2;
40+
statusWaitingMessage = "Test starting, waiting...";
41+
statusReadyMessage = "Test is ready.";
42+
};
43+
44+
# LIVENESS: After startup, use a timer to periodically check health.
45+
liveness-probe = {
46+
enable = true;
47+
command = "[ \"$(nc -w 2 localhost 8080)\" = \"Test2\" ]";
48+
initialDelay = 15;
49+
interval = 30; # Check every 30 seconds.
50+
timeout = 5;
51+
};
52+
};
53+
}

machines/modules/lido-keys-api.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ self, ... }:
2+
{
3+
imports = [
4+
self.modules.nixos.lido-keys-api
5+
];
6+
7+
services.lido-keys-api = {
8+
enable = true;
9+
args = {
10+
port = 3000;
11+
cors-whitelist-regexp = "^https?://(?:.+?\.)?(?:lido|testnet|mainnet|holesky)\.fi$";
12+
global-throttle-ttl = 5;
13+
global-throttle-limit = 100;
14+
global-cache-ttl = 1;
15+
sentry-dsn = "";
16+
log-level = "debug";
17+
log-format = "json";
18+
db-name = "node_operator_keys_service_db";
19+
db-port = 5432;
20+
db-host = "127.0.0.1";
21+
db-user = "postgres";
22+
db-password = ../blankpass.txt;
23+
provider-json-rpc-max-batch-size = 100;
24+
provider-concurrent-requests = 5;
25+
provider-batch-aggregation-wait-ms = 10;
26+
validator-registry-enable = true;
27+
};
28+
};
29+
30+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{ self, config, ... }:
2+
{
3+
imports = [
4+
self.modules.nixos.lido-validator-ejector
5+
];
6+
7+
services.lido-validator-ejector = {
8+
enable = true;
9+
args = {
10+
messages-location = config.services.lido-withdrawals-automation.args.output-folder;
11+
blocks-preload = 100000;
12+
http-port = 8989;
13+
run-metrics = true;
14+
run-health-check = true;
15+
logger-level = "info";
16+
logger-format = "simple";
17+
logger-secrets = [
18+
"MESSAGES_PASSWORD"
19+
"EXECUTION_NODE"
20+
"CONSENSUS_NODE"
21+
];
22+
dry-run = false;
23+
};
24+
};
25+
}

0 commit comments

Comments
 (0)