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
# (e.g., `config.profiles.filesystem.archive.enable = true`) and not have
# 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, ... }:
let
@ -9,25 +13,14 @@ let
in
{
options.profiles.filesystem = {
archive.enable = lib.mkOption {
type = lib.types.bool;
description = ''
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;
setups = {
archive.enable = lib.mkEnableOption "automounting offline archive";
external-hdd.enable = lib.mkEnableOption "automounting personal external hard drive";
};
};
config = lib.mkMerge [
(lib.mkIf cfg.archive.enable {
(lib.mkIf cfg.setups.archive.enable {
fileSystems."/mnt/archives" = {
device = "/dev/disk/by-uuid/6ba86a30-5fa4-41d9-8354-fa8af0f57f49";
fsType = "btrfs";
@ -40,13 +33,10 @@ in
"compress=zstd:9"
"space_cache=v2"
# General mount options from mount.5 manual page.
"noauto"
"nofail"
"user"
# See systemd.mount.5 and systemd.automount.5 manual page for more
# details.
"x-systemd.automount"
"x-systemd.idle-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" = {
device = "/dev/disk/by-uuid/665A391C5A38EB07";
fsType = "ntfs";
@ -64,8 +54,6 @@ in
"noauto"
"user"
# See systemd.mount.5 and systemd.automount.5 manual page for more
# details.
"x-systemd.automount"
"x-systemd.device-timeout=2"
"x-systemd.idle-timeout=2"

View File

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

View File

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