nixos-config/common/hardware/btrfs.nix

37 lines
722 B
Nix
Raw Normal View History

2024-04-22 20:48:35 +02:00
{
lib,
pkgs,
...
}: {
2024-05-01 11:15:45 +02:00
boot.initrd.availableKernelModules = [
# Btrfs CRC hardware acceleration
"crc32c-intel"
];
2024-04-22 04:57:27 +02:00
services.btrfs.autoScrub = {
enable = true;
2024-04-22 20:48:35 +02:00
interval = "monthly";
2024-04-22 05:51:31 +02:00
fileSystems = lib.mkDefault ["/"];
2024-04-22 04:57:27 +02:00
};
2024-04-22 20:48:35 +02:00
systemd.timers."btrfs-snapshot" = {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "weekly";
Persistent = true;
Unit = "btrfs-snapshot.service";
};
};
systemd.services."btrfs-snapshot" = {
script = ''
set -eu
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot /home /snapshots/home/$(date +"%Y-M%m-%d_%H-%M-%S") -r
'';
serviceConfig = {
Type = "oneshot";
User = "root";
};
};
2024-04-22 04:57:27 +02:00
}