diff --git a/devices/srv1/node1/default.nix b/devices/srv1/node1/default.nix index ca876c90..5c7e17c8 100644 --- a/devices/srv1/node1/default.nix +++ b/devices/srv1/node1/default.nix @@ -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" ]; }; diff --git a/devices/srv1/node2/default.nix b/devices/srv1/node2/default.nix index 4ceaa442..02174e03 100644 --- a/devices/srv1/node2/default.nix +++ b/devices/srv1/node2/default.nix @@ -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" ]; }; diff --git a/devices/srv1/node3/default.nix b/devices/srv1/node3/default.nix index 59a75784..c182bb1f 100644 --- a/devices/srv1/node3/default.nix +++ b/devices/srv1/node3/default.nix @@ -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" ]; }; diff --git a/modules/system/fileSystems/nfs.nix b/modules/system/fileSystems/nfs.nix new file mode 100644 index 00000000..3f90ad38 --- /dev/null +++ b/modules/system/fileSystems/nfs.nix @@ -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; + }; +}