feat: c1 and c2 enable roce, zram, and sockets autocleaning

This commit is contained in:
Dict Xiong 2025-10-29 13:48:16 +08:00
parent 123e1cc5e0
commit 45c4338c6b
3 changed files with 28 additions and 2 deletions

View File

@ -10,6 +10,7 @@
enable = true;
serial = 1;
ethLanName = "ens16f0";
ethRDMAName = "ens2f1np1";
};
};
system.stateVersion = "25.05";

View File

@ -10,6 +10,7 @@
enable = true;
serial = 2;
ethLanName = "ens16f0";
ethRDMAName = "ens2f1np1";
};
};
system.stateVersion = "25.05";

View File

@ -276,6 +276,28 @@ in
};
};
};
systemd.timers."home2-sockets-clean" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "0:0:0";
Unit = "home2-sockets-clean.service";
};
};
systemd.services."home2-sockets-clean" = {
serviceConfig = {
Type = "simple";
User = "root";
};
script = ''
cd /home2/run
for i in ./*.sock; do
if ! socat -u OPEN:/dev/null UNIX-CONNECT:$i 1>/dev/null 2>&1; then
rm $i
fi
done
'';
path = [ pkgs.socat ];
};
})
# registry
(lib.mkIf (registryCfg.enable) {
@ -463,6 +485,7 @@ in
(lib.mkIf (cCfg.enable) {
networking.hostName = "c" + (builtins.toString cCfg.serial);
networking.nameservers = [ "192.168.20.1" ];
zramSwap.enable = true;
nasp.docker.enable = lib.mkDefault true;
nasp.registry.enable = lib.mkDefault true;
nasp.nginx.enable = lib.mkDefault true;
@ -486,15 +509,16 @@ in
(lib.mkIf (cCfg.enable && cCfg.ethRDMAName != "") {
systemd.network.networks."10-eth-rdma" = {
matchConfig.Name = cCfg.ethRDMAName;
address = [ "12.12.12.${builtins.toString (cCfg.serial + 100)}/24" ];
address = [ "10.10.10.${builtins.toString (cCfg.serial + 100)}/24" ];
linkConfig.RequiredForOnline = "no";
};
networking.rxe = {
enable = true;
interfaces = [ "${cCfg.ethRDMAName}" ];
};
environment.systemPackages = [ pkgs.rdma-core ];
networking.firewall.extraInputRules = ''
ip saddr 12.12.12.0/24 accept
ip saddr 10.10.10.0/24 accept
'';
})
]);