41 lines
1.1 KiB
Nix
41 lines
1.1 KiB
Nix
{ config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.numbus.hardware.disks;
|
|
|
|
contentCount = builtins.length cfg.content.list;
|
|
parityCount = builtins.length cfg.parity.list;
|
|
in
|
|
|
|
{
|
|
config = mkIf (contentCount >= 2 && parityCount >= 1) {
|
|
services.snapraid = {
|
|
enable = true;
|
|
contentFiles = map (i: "/mnt/content-${toString i}/snapraid.content") (range 0 (contentCount - 1));
|
|
parityFiles = map (i: "/mnt/parity-${toString i}/snapraid.parity") (range 0 (parityCount - 1));
|
|
dataDisks = listToAttrs (imap0 (i: _: nameValuePair "d${toString i}" "/mnt/content-${toString i}") cfg.content.list);
|
|
};
|
|
|
|
fileSystems."/mnt/data" = {
|
|
device = concatStringsSep ":" (map (i: "/mnt/content-${toString i}") (range 0 (contentCount - 1)));
|
|
fsType = "fuse.mergerfs";
|
|
options = [
|
|
"category.create=ff"
|
|
"cache.files=partial"
|
|
"dropcacheonclose=true"
|
|
"defaults"
|
|
"noauto"
|
|
"nofail"
|
|
"allow_other"
|
|
"moveonenospc=1"
|
|
"minfreespace=50G"
|
|
"func.getattr=newest"
|
|
"fsname=mergerfs_data"
|
|
"x-mount.mkdir"
|
|
"x-systemd.automount"
|
|
];
|
|
};
|
|
};
|
|
} |