feat(nas): make snapraid module
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
d15c124b0b
commit
0dddbb7734
2 changed files with 67 additions and 9 deletions
|
@ -37,55 +37,55 @@ in {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
"3tb-1" = {
|
"d1 3tb-1" = {
|
||||||
mountPoint = "/mnt/drives/3tb1";
|
mountPoint = "/mnt/drives/3tb1";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N1236473-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N1236473-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"3tb-2" = {
|
"d2 3tb-2" = {
|
||||||
mountPoint = "/mnt/drives/3tb2";
|
mountPoint = "/mnt/drives/3tb2";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N1233153-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N1233153-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"4tb-1" = {
|
"d3 4tb-1" = {
|
||||||
mountPoint = "/mnt/drives/4tb1";
|
mountPoint = "/mnt/drives/4tb1";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD40EZAZ-19SF3B0_WD-WX32D81DE8RD-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD40EZAZ-19SF3B0_WD-WX32D81DE8RD-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"4tb-2" = {
|
"d4 4tb-2" = {
|
||||||
mountPoint = "/mnt/drives/4tb2";
|
mountPoint = "/mnt/drives/4tb2";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD40EZAZ-19SF3B0_WD-WX32D81DE6Z0-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD40EZAZ-19SF3B0_WD-WX32D81DE6Z0-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"8tb-1" = {
|
"d5 8tb-1" = {
|
||||||
mountPoint = "/mnt/drives/8tb1";
|
mountPoint = "/mnt/drives/8tb1";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD8003FFBX-68B9AN0_VAJ99UDL-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD8003FFBX-68B9AN0_VAJ99UDL-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"8tb-2 parity0" = {
|
"p0 8tb-2" = {
|
||||||
mountPoint = "/mnt/drives/parity0";
|
mountPoint = "/mnt/drives/parity0";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD8003FFBX-68B9AN0_VDGL4HZD-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD8003FFBX-68B9AN0_VDGL4HZD-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"8tb-3 parity1" = {
|
"p1 8tb-3" = {
|
||||||
mountPoint = "/mnt/drives/parity1";
|
mountPoint = "/mnt/drives/parity1";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD80EFZZ-68BTXN0_WD-CA13WUYK-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD80EFZZ-68BTXN0_WD-CA13WUYK-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"8tb-4" = {
|
"d6 8tb-4" = {
|
||||||
mountPoint = "/mnt/drives/8tb4";
|
mountPoint = "/mnt/drives/8tb4";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD80EAZZ-00BKLB0_WD-CA1AVU7K-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD80EAZZ-00BKLB0_WD-CA1AVU7K-part1";
|
||||||
};
|
};
|
||||||
|
|
||||||
"8tb-5" = {
|
"d7 8tb-5" = {
|
||||||
mountPoint = "/mnt/drives/8tb5";
|
mountPoint = "/mnt/drives/8tb5";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
device = "/dev/disk/by-id/ata-WDC_WD80EAZZ-00BKLB0_WD-CA1GN0GK-part1";
|
device = "/dev/disk/by-id/ata-WDC_WD80EAZZ-00BKLB0_WD-CA1GN0GK-part1";
|
||||||
|
|
58
devices/nas/modules/snapraid.nix
Normal file
58
devices/nas/modules/snapraid.nix
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit
|
||||||
|
(lib)
|
||||||
|
attrValues
|
||||||
|
filterAttrs
|
||||||
|
hasPrefix
|
||||||
|
listToAttrs
|
||||||
|
mapAttrs
|
||||||
|
optionalString
|
||||||
|
substring
|
||||||
|
toInt
|
||||||
|
;
|
||||||
|
|
||||||
|
parityDrives = filterAttrs (n: v: hasPrefix "p" n) config.fileSystems;
|
||||||
|
dataDrives = filterAttrs (n: v: hasPrefix "d" n) config.fileSystems;
|
||||||
|
in {
|
||||||
|
snapraid = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
dataDisks = listToAttrs (attrValues (mapAttrs (n: fs: {
|
||||||
|
name = substring 0 2 n;
|
||||||
|
value = fs.mountPoint;
|
||||||
|
})
|
||||||
|
dataDrives));
|
||||||
|
|
||||||
|
parityFiles = attrValues (mapAttrs (n: fs: "${fs.mountPoint}/snapraid.${
|
||||||
|
let
|
||||||
|
i = (toInt (substring 1 1 n)) + 1;
|
||||||
|
in
|
||||||
|
optionalString (i != 1) "${toString i}-"
|
||||||
|
}parity")
|
||||||
|
parityDrives);
|
||||||
|
|
||||||
|
contentFiles =
|
||||||
|
["/var/snapraid/content"]
|
||||||
|
++ map (fs: "${fs.mountPoint}/content") (attrValues dataDrives);
|
||||||
|
|
||||||
|
exclude = [
|
||||||
|
"*.bak"
|
||||||
|
"*.unrecoverable"
|
||||||
|
"/tmp/"
|
||||||
|
"/lost+found/"
|
||||||
|
".AppleDouble"
|
||||||
|
"._AppleDouble"
|
||||||
|
".DS_Store"
|
||||||
|
".Thumbs.db"
|
||||||
|
".fseventsd"
|
||||||
|
".Spotlight-V100"
|
||||||
|
".TemporaryItems"
|
||||||
|
".Trashes"
|
||||||
|
".AppleDB"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue