feat: update nfs and samba settings to allow for custom folder and mount paths

This commit is contained in:
Ceferino Patino 2026-05-30 23:34:21 -05:00
commit fe12f1e2ef
Signed by: c4patino
SSH key fingerprint: SHA256:Wu+cU1t+7zVT9wzew/4meNmeulo66NzMqc22MdDBgXI
5 changed files with 62 additions and 18 deletions

View file

@ -35,20 +35,38 @@ in {
description = "List of the folder paths to share via NFS.";
};
mounts = mkOption {
type = attrsOf str;
type = attrsOf (submodule {
options.host = mkOption {
type = str;
description = "Target host to mount from.";
};
options.folder = mkOption {
type = str;
description = "Remote folder path on the NFS server.";
};
options.mountPath = mkOption {
type = nullOr str;
default = null;
description = "Local mount path. If null, defaults to /mnt/nfs/{name}.";
};
});
default = {};
description = "Set of folder paths to mount via NFS with the target host.";
description = "Set of NFS mounts with custom configuration.";
};
};
config = {
fileSystems = let
mapFolderToMount = folder: host: let
hostIP = resolveHostIP networkCfg.devices host;
mapFolderToMount = name: mntCfg: let
hostIP = resolveHostIP networkCfg.devices mntCfg.host;
localPath =
if mntCfg.mountPath != null
then mntCfg.mountPath
else "/mnt/nfs/${name}";
in {
name = "/mnt/nfs/${folder}";
name = localPath;
value = {
device = "${hostIP}:/mnt/nfs/${folder}";
device = "${hostIP}:${mntCfg.folder}";
fsType = "nfs";
};
};

View file

@ -21,21 +21,39 @@ in {
description = "List of folder paths to share via Samba.";
};
mounts = mkOption {
type = attrsOf str;
type = attrsOf (submodule {
options.host = mkOption {
type = str;
description = "Target host to mount from.";
};
options.folder = mkOption {
type = str;
description = "Remote folder/share name on the Samba server.";
};
options.mountPath = mkOption {
type = nullOr str;
default = null;
description = "Local mount path. If null, defaults to /mnt/samba/{name}.";
};
});
default = {};
description = "List of the folder paths to mount via Samba and the host.";
description = "Set of Samba mounts with custom configuration.";
};
};
config = {
fileSystems = let
processMount = folder: host: let
hostIP = resolveHostIP networkCfg.devices host;
processMount = name: mountCfg: let
hostIP = resolveHostIP networkCfg.devices mountCfg.host;
localPath =
if mountCfg.mountPath != null
then mountCfg.mountPath
else "/mnt/samba/${name}";
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in {
name = "/mnt/samba/${folder}";
name = localPath;
value = {
device = "//${hostIP}/${folder}";
device = "//${hostIP}/${mountCfg.folder}";
fsType = "cifs";
options = [
"${automount_opts},credentials=/etc/samba/.credentials,uid=1000,gid=100"

View file

@ -67,14 +67,16 @@ in {
};
storage = {
nfs.mounts = {
"slurm" = "chibi";
};
samba = {
enable = true;
shares = ["shared"];
};
nfs.mounts = {
slurm = {
host = "chibi";
folder = "/mnt/nfs/slurm";
};
};
};
};
};

View file

@ -36,7 +36,10 @@ in {
storage = {
samba.mounts = {
"shared" = "arisu";
shared = {
host = "arisu";
folder = "shared";
};
};
};
};

View file

@ -39,7 +39,10 @@ in {
storage = {
samba.mounts = {
"shared" = "arisu";
shared = {
host = "arisu";
folder = "shared";
};
};
};
};