Added snapRAID and MergerFS Nix config.
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
{ modulesPath, config, lib, pkgs, inputs, ... }:
|
||||
|
||||
let
|
||||
# Create a list of data disk mount points, e.g. [ "/mnt/data-1" "/mnt/data-2" ]
|
||||
dataDisks = lib.lists.catAttrs "mountpoint" (
|
||||
lib.attrsets.filterAttrs (n: v: lib.strings.hasPrefix "data-" n) config.disko.devices.disk
|
||||
);
|
||||
|
||||
# Create a list of parity disk mount points
|
||||
parityDisks = lib.lists.catAttrs "mountpoint" (
|
||||
lib.attrsets.filterAttrs (n: v: lib.strings.hasPrefix "parity-" n) config.disko.devices.disk
|
||||
);
|
||||
in
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
@@ -153,5 +165,36 @@
|
||||
# Enable NixOS flakes
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
|
||||
# --- Storage Configuration (MergerFS & SnapRAID) ---
|
||||
|
||||
# Create the mount point for the MergerFS pool
|
||||
fileSystems."/mnt/data-storage" = {
|
||||
device = "mergerfs";
|
||||
fsType = "fuse";
|
||||
options = [
|
||||
"defaults"
|
||||
"allow_other"
|
||||
"use_ino"
|
||||
"cache.files=off"
|
||||
"moveonenospc=true"
|
||||
"category.create=mfs"
|
||||
"srcmounts=${lib.strings.concatStringsSep ":" dataDisks}"
|
||||
];
|
||||
};
|
||||
|
||||
# SnapRAID for data redundancy
|
||||
services.snapraid = {
|
||||
enable = true;
|
||||
content = map (disk: "${disk}/snapraid.content") dataDisks;
|
||||
parity = map (disk: "${disk}/snapraid.parity") parityDisks;
|
||||
data = dataDisks;
|
||||
|
||||
runner = {
|
||||
enable = true;
|
||||
diffAndSyncOn = "04:00"; # Daily at 4am
|
||||
scrubOn = "Sun 05:00"; # Weekly on Sunday at 5am
|
||||
};
|
||||
};
|
||||
|
||||
system.stateVersion = "25.05";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user