From fe12f1e2ef5c680dae4e36b98fc71a812747c89f Mon Sep 17 00:00:00 2001 From: C4 Patino Date: Sat, 30 May 2026 23:34:21 -0500 Subject: [PATCH] feat: update nfs and samba settings to allow for custom folder and mount paths --- .../nixos/services/storage/nfs/default.nix | 30 +++++++++++++++---- .../nixos/services/storage/samba/default.nix | 30 +++++++++++++++---- systems/x86_64-linux/arisu/default.nix | 10 ++++--- systems/x86_64-linux/kokoro/default.nix | 5 +++- systems/x86_64-linux/tsuki/default.nix | 5 +++- 5 files changed, 62 insertions(+), 18 deletions(-) diff --git a/modules/nixos/services/storage/nfs/default.nix b/modules/nixos/services/storage/nfs/default.nix index f5c89e1..6026d09 100644 --- a/modules/nixos/services/storage/nfs/default.nix +++ b/modules/nixos/services/storage/nfs/default.nix @@ -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"; }; }; diff --git a/modules/nixos/services/storage/samba/default.nix b/modules/nixos/services/storage/samba/default.nix index 8036b7a..a3c3144 100644 --- a/modules/nixos/services/storage/samba/default.nix +++ b/modules/nixos/services/storage/samba/default.nix @@ -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" diff --git a/systems/x86_64-linux/arisu/default.nix b/systems/x86_64-linux/arisu/default.nix index 48eda72..c3faf90 100644 --- a/systems/x86_64-linux/arisu/default.nix +++ b/systems/x86_64-linux/arisu/default.nix @@ -67,14 +67,16 @@ in { }; storage = { - nfs.mounts = { - "slurm" = "chibi"; - }; - samba = { enable = true; shares = ["shared"]; }; + nfs.mounts = { + slurm = { + host = "chibi"; + folder = "/mnt/nfs/slurm"; + }; + }; }; }; }; diff --git a/systems/x86_64-linux/kokoro/default.nix b/systems/x86_64-linux/kokoro/default.nix index c42102c..424f6ce 100644 --- a/systems/x86_64-linux/kokoro/default.nix +++ b/systems/x86_64-linux/kokoro/default.nix @@ -36,7 +36,10 @@ in { storage = { samba.mounts = { - "shared" = "arisu"; + shared = { + host = "arisu"; + folder = "shared"; + }; }; }; }; diff --git a/systems/x86_64-linux/tsuki/default.nix b/systems/x86_64-linux/tsuki/default.nix index 2ae5407..4ac0299 100755 --- a/systems/x86_64-linux/tsuki/default.nix +++ b/systems/x86_64-linux/tsuki/default.nix @@ -39,7 +39,10 @@ in { storage = { samba.mounts = { - "shared" = "arisu"; + shared = { + host = "arisu"; + folder = "shared"; + }; }; }; };