60 lines
1.7 KiB
Nix
60 lines
1.7 KiB
Nix
{ config, pkgs, lib, ... }: let
|
|
cfg = config.internal.nas0;
|
|
in {
|
|
options = {
|
|
internal.nas0 = {
|
|
useSMB = lib.mkEnableOption "use SMB to connect to nas0";
|
|
useNFS = lib.mkEnableOption "use NFS to connect to nas0";
|
|
useiSCSI = lib.mkEnableOption "use iSCSI to connect to nas0";
|
|
|
|
mountUid = lib.mkOption {
|
|
type = lib.types.number;
|
|
default = 1000;
|
|
description = ''
|
|
UID for the mount
|
|
'';
|
|
};
|
|
|
|
mountGid = lib.mkOption {
|
|
type = lib.types.number;
|
|
default = 100;
|
|
description = ''
|
|
GID for the mount
|
|
'';
|
|
};
|
|
|
|
lazyMount = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = ''enable systemd lazy mounting'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
sops.secrets.smb_credentials = {
|
|
sopsFile = ../../secrets/default.yaml;
|
|
};
|
|
|
|
fileSystems."/mnt/nas0" = let
|
|
automount_opts = if cfg.lazyMount then "x-systemd.automount,noauto,x-systemd.idle-timeout=60" else "";
|
|
in {
|
|
device = if cfg.useSMB then "//nas0.hoki-porgy.ts.net/main/" else "nas0.hoki-porgy.ts.net:/storage";
|
|
fsType = if cfg.useSMB then "cifs" else "nfs";
|
|
options = let
|
|
typeOptions = if cfg.useSMB
|
|
then "credentials=${config.sops.secrets.smb_credentials.path},uid=${toString cfg.mountUid},gid=${toString cfg.mountGid}"
|
|
else "nfsvers=4.2";
|
|
in [
|
|
"${automount_opts},x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"
|
|
"X-mount.mkdir"
|
|
typeOptions
|
|
];
|
|
};
|
|
|
|
environment.systemPackages = lib.mkIf cfg.useSMB [
|
|
pkgs.cifs-utils
|
|
pkgs.samba
|
|
];
|
|
};
|
|
}
|