modules.system.fileSystems.nfs: init

This commit is contained in:
陈浩南 2024-09-26 12:16:15 +08:00
parent 515b6eedc1
commit e72bec278e
4 changed files with 35 additions and 70 deletions

View File

@ -13,6 +13,7 @@ inputs:
eno2 = { ip = "192.168.178.2"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
};
cluster.nodeType = "worker";
fileSystems.mount.nfs."192.168.178.1:/home" = "/home";
};
services.beesd.instances.root = { device = "/"; hashTableSizeMB = 256; threads = 4; };
packages.packages._prebuildPackages =
@ -20,31 +21,10 @@ inputs:
};
specialisation.no-share-home.configuration =
{
nixos =
{
services.slurm.enable = inputs.lib.mkForce false;
system.cluster.nodeType = inputs.lib.mkForce "master";
};
nixos.system.fileSystems.mount.nfs = inputs.lib.mkForce null;
system.nixos.tags = [ "no-share-home" ];
};
fileSystems = inputs.lib.mkIf (inputs.config.nixos.system.cluster.nodeType == "worker")
{
"/home" =
{
device = "192.168.178.1:/home";
fsType = "nfs";
neededForBoot = true;
};
};
boot.initrd.network.enable = true;
boot.initrd.systemd.network.networks."10-eno2" = inputs.config.systemd.network.networks."10-eno2";
boot.initrd.systemd.extraBin =
{
"ifconfig" = "${inputs.pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs4";
};
services.rpcbind.enable = true;
# make slurm sub process to be able to communicate with the master
networking.firewall.trustedInterfaces = [ "eno2" ];
};

View File

@ -10,8 +10,7 @@ inputs:
networking.networkd.static.eno2 =
{ ip = "192.168.178.3"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
cluster.nodeType = "worker";
initrd.sshd.enable = true;
nix.remote.slave.enable = true;
fileSystems.mount.nfs."192.168.178.1:/home" = "/home";
};
services.beesd.instances.root = { device = "/"; hashTableSizeMB = 256; threads = 4; };
packages.packages._prebuildPackages =
@ -19,31 +18,10 @@ inputs:
};
specialisation.no-share-home.configuration =
{
nixos =
{
services.slurm.enable = inputs.lib.mkForce false;
system.cluster.nodeType = inputs.lib.mkForce "master";
};
nixos.system.fileSystems.mount.nfs = inputs.lib.mkForce null;
system.nixos.tags = [ "no-share-home" ];
};
fileSystems = inputs.lib.mkIf (inputs.config.nixos.system.cluster.nodeType == "worker")
{
"/home" =
{
device = "192.168.178.1:/home";
fsType = "nfs";
neededForBoot = true;
};
};
boot.initrd.network.enable = true;
boot.initrd.systemd.network.networks."10-eno2" = inputs.config.systemd.network.networks."10-eno2";
boot.initrd.systemd.extraBin =
{
"ifconfig" = "${inputs.pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs4";
};
services.rpcbind.enable = true;
# make slurm sub process to be able to communicate with the master
networking.firewall.trustedInterfaces = [ "eno2" ];
};

View File

@ -10,8 +10,7 @@ inputs:
networking.networkd.static.eno2 =
{ ip = "192.168.178.4"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
cluster.nodeType = "worker";
initrd.sshd.enable = true;
nix.remote.slave.enable = true;
fileSystems.mount.nfs."192.168.178.1:/home" = "/home";
};
services.beesd.instances.root = { device = "/"; hashTableSizeMB = 256; threads = 4; };
packages.packages._prebuildPackages =
@ -19,31 +18,10 @@ inputs:
};
specialisation.no-share-home.configuration =
{
nixos =
{
services.slurm.enable = inputs.lib.mkForce false;
system.cluster.nodeType = inputs.lib.mkForce "master";
};
nixos.system.fileSystems.mount.nfs = inputs.lib.mkForce null;
system.nixos.tags = [ "no-share-home" ];
};
fileSystems = inputs.lib.mkIf (inputs.config.nixos.system.cluster.nodeType == "worker")
{
"/home" =
{
device = "192.168.178.1:/home";
fsType = "nfs";
neededForBoot = true;
};
};
boot.initrd.network.enable = true;
boot.initrd.systemd.network.networks."10-eno2" = inputs.config.systemd.network.networks."10-eno2";
boot.initrd.systemd.extraBin =
{
"ifconfig" = "${inputs.pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs4";
};
services.rpcbind.enable = true;
# make slurm sub process to be able to communicate with the master
networking.firewall.trustedInterfaces = [ "eno2" ];
};

View File

@ -0,0 +1,29 @@
inputs:
{
imports = inputs.localLib.findModules ./.;
options.nixos.system.fileSystems.mount.nfs = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.attrsOf types.nonEmptyStr); default = null;
};
config = let inherit (inputs.config.nixos.system.fileSystems.mount) nfs; in inputs.lib.mkIf (nfs != null)
{
fileSystems = builtins.listToAttrs (builtins.map
(device:
{
name = device.value;
value = { device = device.name; fsType = "nfs"; neededForBoot = true; };
})
(inputs.localLib.attrsToList nfs));
boot.initrd =
{
network.enable = true;
systemd.extraBin =
{
"ifconfig" = "${inputs.pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs4";
};
};
services.rpcbind.enable = true;
};
}