feat: refactored impermanence modules to follow new pattern
This commit is contained in:
parent
3ca0e9bf0a
commit
b67be1472a
54 changed files with 718 additions and 640 deletions
62
modules/nixos-modules/server/qbittorent/storage.nix
Normal file
62
modules/nixos-modules/server/qbittorent/storage.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
qbittorent_profile_directory = "/var/lib/qBittorrent/";
|
||||
in {
|
||||
options.services.qbittorrent.impermanence.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = config.services.qbittorrent.enable && config.storage.impermanence.enable;
|
||||
};
|
||||
|
||||
config = lib.mkIf config.services.qbittorrent.enable (lib.mkMerge [
|
||||
(lib.mkIf config.storage.zfs.enable (lib.mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.services.qbittorrent.profileDir == qbittorent_profile_directory;
|
||||
message = "qbittorrent data directory does not match persistence";
|
||||
}
|
||||
];
|
||||
}
|
||||
(lib.mkIf (!config.services.qbittorrent.impermanence.enable) {
|
||||
# TODO: placeholder to configure a unique dataset for this service
|
||||
})
|
||||
(
|
||||
lib.mkIf config.services.qbittorrent.impermanence.enable
|
||||
{
|
||||
storage.impermanence.datasets = {
|
||||
"persist/system/root" = {
|
||||
directories."${qbittorent_profile_directory}" = {
|
||||
owner.name = "qbittorrent";
|
||||
group.name = "qbittorrent";
|
||||
};
|
||||
};
|
||||
"persist/system/qbittorrent" = {
|
||||
directories."${config.services.qbittorrent.mediaDir}" = {
|
||||
owner.name = "qbittorrent";
|
||||
group.name = "qbittorrent";
|
||||
owner.permissions = {
|
||||
read = true;
|
||||
write = true;
|
||||
execute = true;
|
||||
};
|
||||
group.permissions = {
|
||||
read = true;
|
||||
write = true;
|
||||
execute = true;
|
||||
};
|
||||
other.permissions = {
|
||||
read = true;
|
||||
write = false;
|
||||
execute = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
]))
|
||||
]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue