profiles/filesystem: add setups namespace

There will be added options that are not exactly filesystem setups.
This commit is contained in:
Gabriel Arazas 2023-07-24 15:15:55 +08:00
parent 4edd63f411
commit 8777fc06e8
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
3 changed files with 11 additions and 23 deletions

View File

@ -2,6 +2,10 @@
# nice for setting up shop for certain tasks with the flick of the switch to ON # nice for setting up shop for certain tasks with the flick of the switch to ON
# (e.g., `config.profiles.filesystem.archive.enable = true`) and not have # (e.g., `config.profiles.filesystem.archive.enable = true`) and not have
# conflicting settings all throughout the configuration. # conflicting settings all throughout the configuration.
#
# Much of the filesystem setups are taking advantage of systemd's fstab
# extended options which you can refer to at systemd.mount(5), mount(5), and
# the filesystems' respective manual pages.
{ config, options, lib, pkgs, ... }: { config, options, lib, pkgs, ... }:
let let
@ -9,25 +13,14 @@ let
in in
{ {
options.profiles.filesystem = { options.profiles.filesystem = {
archive.enable = lib.mkOption { setups = {
type = lib.types.bool; archive.enable = lib.mkEnableOption "automounting offline archive";
description = '' external-hdd.enable = lib.mkEnableOption "automounting personal external hard drive";
Add the archive storage to the list of filesystems.
'';
default = false;
};
external-hdd.enable = lib.mkOption {
type = lib.types.bool;
description = ''
Add the external hard drive to the list of filesystems.
'';
default = false;
}; };
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf cfg.archive.enable { (lib.mkIf cfg.setups.archive.enable {
fileSystems."/mnt/archives" = { fileSystems."/mnt/archives" = {
device = "/dev/disk/by-uuid/6ba86a30-5fa4-41d9-8354-fa8af0f57f49"; device = "/dev/disk/by-uuid/6ba86a30-5fa4-41d9-8354-fa8af0f57f49";
fsType = "btrfs"; fsType = "btrfs";
@ -40,13 +33,10 @@ in
"compress=zstd:9" "compress=zstd:9"
"space_cache=v2" "space_cache=v2"
# General mount options from mount.5 manual page.
"noauto" "noauto"
"nofail" "nofail"
"user" "user"
# See systemd.mount.5 and systemd.automount.5 manual page for more
# details.
"x-systemd.automount" "x-systemd.automount"
"x-systemd.idle-timeout=2" "x-systemd.idle-timeout=2"
"x-systemd.device-timeout=2" "x-systemd.device-timeout=2"
@ -54,7 +44,7 @@ in
}; };
}) })
(lib.mkIf cfg.external-hdd.enable { (lib.mkIf cfg.setups.external-hdd.enable {
fileSystems."/mnt/external-storage" = { fileSystems."/mnt/external-storage" = {
device = "/dev/disk/by-uuid/665A391C5A38EB07"; device = "/dev/disk/by-uuid/665A391C5A38EB07";
fsType = "ntfs"; fsType = "ntfs";
@ -64,8 +54,6 @@ in
"noauto" "noauto"
"user" "user"
# See systemd.mount.5 and systemd.automount.5 manual page for more
# details.
"x-systemd.automount" "x-systemd.automount"
"x-systemd.device-timeout=2" "x-systemd.device-timeout=2"
"x-systemd.idle-timeout=2" "x-systemd.idle-timeout=2"

View File

@ -59,7 +59,7 @@ in
"ssh-key" = { }; "ssh-key" = { };
}); });
profiles.filesystem = { profiles.filesystem.setups = {
archive.enable = true; archive.enable = true;
external-hdd.enable = true; external-hdd.enable = true;
}; };

View File

@ -100,7 +100,7 @@ in
"secrets-config" = { }; "secrets-config" = { };
}); });
profiles.filesystem.archive.enable = true; profiles.filesystem.setups.archive.enable = true;
services.yt-dlp = { services.yt-dlp = {
enable = true; enable = true;