···
cfg = config.cyclamen.system.lannas;
8
+
mountUsers = if cfg.enable == "all" || cfg.enable == "users" then true else false;
9
+
mountSystem = if cfg.enable == "all" || cfg.enable == "system" then true else false;
credFile = "/etc/nixos/nas_secrets";
rootBackupsPath = "main/backup/nel";
···
automountConfig.TimeoutIdleSec = 60;
40
-
options.cyclamen.system.lannas.enable = lib.mkEnableOption ''
41
-
mounting of directories from the LAN NAS. mainly intended for backups.
42
+
options.cyclamen.system.lannas.enable = lib.mkOption {
43
+
type = lib.types.enum [ "no" "system" "users" "all" ];
47
+
Whether to enable mounting of directories from the LAN NAS. mainly intended for backups.
49
+
"no" mounts nothing.
50
+
"system" mounts only the system mount based on hostname.
51
+
"users" mounts only the user mounts for isNormalUser users.
52
+
"all" mounts both the system mount and user mount.
44
-
config = lib.mkIf cfg.enable {
56
+
config = lib.mkIf (cfg.enable != "no") {
boot.supportedFilesystems = [ "cifs" ];
# For mount.cifs, required unless domain name resolution is not needed.
environment.systemPackages = [ pkgs.cifs-utils ];
···
# We use systemd mount units directly instead of fileSystems.* to avoid infinite recursion.
# See https://github.com/NixOS/nixpkgs/issues/24570 for details
52
-
mounts = (lib.lists.map usernameToMountUnit normalUsers) ++ [ (hostnameToMountUnit config.networking.hostName) ];
53
-
automounts = (lib.lists.map usernameToAutomountUnit normalUsers) ++ [ (hostnameToAutomountUnit config.networking.hostName) ];
64
+
mounts = (lib.lists.optionals mountUsers (lib.lists.map usernameToMountUnit normalUsers))
65
+
++ (lib.lists.optional mountSystem (hostnameToMountUnit config.networking.hostName));
66
+
automounts = (lib.lists.optionals mountUsers (lib.lists.map usernameToAutomountUnit normalUsers))
67
+
++ (lib.lists.optional mountSystem (hostnameToAutomountUnit config.networking.hostName));