Merge branch 'switch-srv2' into production

This commit is contained in:
2025-07-03 12:35:16 +08:00
4 changed files with 30 additions and 11 deletions

View File

@@ -18,6 +18,7 @@ inputs:
{ mountPoint = "/nix/remote/pc"; hard = false; };
};
swap = [ "/nix/swap/swap" ];
cluster.masterAddress = "2";
};
nixpkgs.cuda.capabilities =
[
@@ -38,7 +39,7 @@ inputs:
slurm =
{
enable = true;
master = "srv2-node0";
master = "srv2-node1";
node =
{
srv2-node0 =

View File

@@ -4,13 +4,12 @@ inputs:
{
nixos =
{
model.cluster.nodeType = "master";
system =
{
nixpkgs.march = "skylake";
network =
{
static.eno2 = { ip = "192.168.178.1"; mask = 24; };
static.eno2 = { ip = "192.168.178.1"; mask = 24; gateway = "192.168.178.2"; dns = "192.168.178.2"; };
wireless = [ "4575G" ];
masquerade = [ "eno2" ];
trust = [ "eno2" ];

View File

@@ -4,14 +4,16 @@ inputs:
{
nixos =
{
model.cluster.nodeType = "master";
system =
{
nixpkgs.march = "znver3";
network =
{
static.enp58s0 =
{ ip = "192.168.178.2"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
static.enp58s0 = { ip = "192.168.178.2"; mask = 24; };
trust = [ "enp58s0" ];
wireless = [ "4575G" ];
masquerade = [ "enp58s0" ];
};
};
services.beesd."/".hashTableSizeMB = 64;

View File

@@ -1,13 +1,15 @@
inputs:
{
options.nixos.system.fileSystems.cluster = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule { options =
{
masterAddress = mkOption { type = types.str; default = "1"; };
};});
default = if inputs.config.nixos.model.cluster != null then {} else null;
};
config = inputs.lib.mkMerge
[
# for cluster master, export NFS
(inputs.lib.mkIf (inputs.config.nixos.model.cluster.nodeType or null == "master")
{ nixos.services.nfs."/" = [ "192.168.178.0/24" ]; })
# for cluster worker, mount nfs, disable some home manager files
(let inherit (inputs.config.nixos.model) cluster; in inputs.lib.mkIf (cluster.nodeType or null == "worker")
{ nixos.system.fileSystems.mount.nfs."192.168.178.1:/" = "/nix/remote/${cluster.clusterName}"; })
# 将一部分由 home-manager 生成软链接的文件改为直接挂载,以兼容集群的设置
(let files = [ ".zshrc" ".zshenv" ".profile" ".bashrc" ".bash_profile" ".zlogin" ]; in
{
@@ -32,5 +34,20 @@ inputs:
)
inputs.config.nixos.user.users);
})
(
let
fsCluster = inputs.config.nixos.system.fileSystems.cluster;
inherit (inputs.config.nixos.model) cluster;
in inputs.lib.mkIf (fsCluster != null)
{
nixos =
{
services.nfs = inputs.lib.mkIf (cluster.nodeType or null == "master") { "/" = [ "192.168.178.0/24" ]; };
system.fileSystems.mount.nfs = inputs.lib.mkIf (cluster.nodeType or null == "worker")
{
"192.168.178.${fsCluster.masterAddress}:/" = "/nix/remote/${cluster.clusterName}";
};
};
})
];
}