NixOS and Home Manager config

feat(lannas): allow enabling system and user mounts individually

nel.pet 8ba20ed0 b702df67

verified
Changed files
+21 -7
modules
nixos
systems
nel-desktop
+20 -6
modules/nixos/lannas.nix
···
...
}: let
cfg = config.cyclamen.system.lannas;
# TODO: secrets stuff
credFile = "/etc/nixos/nas_secrets";
rootBackupsPath = "main/backup/nel";
···
automountConfig.TimeoutIdleSec = 60;
};
in {
-
options.cyclamen.system.lannas.enable = lib.mkEnableOption ''
-
mounting of directories from the LAN NAS. mainly intended for backups.
-
'';
-
config = lib.mkIf cfg.enable {
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
systemd = {
-
mounts = (lib.lists.map usernameToMountUnit normalUsers) ++ [ (hostnameToMountUnit config.networking.hostName) ];
-
automounts = (lib.lists.map usernameToAutomountUnit normalUsers) ++ [ (hostnameToAutomountUnit config.networking.hostName) ];
};
};
}
···
...
}: let
cfg = config.cyclamen.system.lannas;
+
mountUsers = if cfg.enable == "all" || cfg.enable == "users" then true else false;
+
mountSystem = if cfg.enable == "all" || cfg.enable == "system" then true else false;
# TODO: secrets stuff
credFile = "/etc/nixos/nas_secrets";
rootBackupsPath = "main/backup/nel";
···
automountConfig.TimeoutIdleSec = 60;
};
in {
+
options.cyclamen.system.lannas.enable = lib.mkOption {
+
type = lib.types.enum [ "no" "system" "users" "all" ];
+
default = "no";
+
example = "all";
+
description = ''
+
Whether to enable mounting of directories from the LAN NAS. mainly intended for backups.
+
+
"no" mounts nothing.
+
"system" mounts only the system mount based on hostname.
+
"users" mounts only the user mounts for isNormalUser users.
+
"all" mounts both the system mount and user mount.
+
'';
+
};
+
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
systemd = {
+
mounts = (lib.lists.optionals mountUsers (lib.lists.map usernameToMountUnit normalUsers))
+
++ (lib.lists.optional mountSystem (hostnameToMountUnit config.networking.hostName));
+
automounts = (lib.lists.optionals mountUsers (lib.lists.map usernameToAutomountUnit normalUsers))
+
++ (lib.lists.optional mountSystem (hostnameToAutomountUnit config.networking.hostName));
};
};
}
+1 -1
systems/nel-desktop/configuration.nix
···
cyclamen = {
system = {
-
lannas.enable = true;
};
};
···
cyclamen = {
system = {
+
lannas.enable = "all";
};
};