mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-22 21:18:44 +08:00
modules.system.fileSystems.nfs: init
This commit is contained in:
parent
515b6eedc1
commit
e72bec278e
@ -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" ];
|
||||
};
|
||||
|
@ -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" ];
|
||||
};
|
||||
|
@ -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" ];
|
||||
};
|
||||
|
29
modules/system/fileSystems/nfs.nix
Normal file
29
modules/system/fileSystems/nfs.nix
Normal 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;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user