summaryrefslogtreecommitdiff
path: root/sys/fs/btrfs.nix
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2024-07-14 17:53:13 -0600
committerAlejandro Soto <alejandro@34project.org>2024-07-15 09:34:00 -0600
commit02abf4ed0131237c25e0a10db50fa4c41a902a50 (patch)
tree20904894fc0952806e341cdaff5941e81b3ce51c /sys/fs/btrfs.nix
parent08e746700341dda3e3bdf704332fc3c07053d3e7 (diff)
sys: final merge of dmz, hv into sys
Diffstat (limited to '')
-rw-r--r--sys/btrfs/snapper.nix (renamed from sys/fs/btrfs.nix)59
1 files changed, 8 insertions, 51 deletions
diff --git a/sys/fs/btrfs.nix b/sys/btrfs/snapper.nix
index f240b0d..27d2779 100644
--- a/sys/fs/btrfs.nix
+++ b/sys/btrfs/snapper.nix
@@ -1,60 +1,17 @@
-{ lib, config, pkgs, ... }:
+{ config, lib, pkgs, ... }:
with lib; let
- cfg = config.local;
+ cfg = config.local.btrfs;
in
{
- options.local = with lib.types; {
- snapperSubvols = mkOption {
- type = attrsOf str;
+ options.local.btrfs = {
+ snapper = mkOption {
+ type = with lib.types; attrsOf str;
default = { };
};
-
- fs.btrfs = mkOption {
- default = [ ];
-
- type = attrsOf (submodule {
- options = {
- device = mkOption {
- type = str;
- };
-
- subvol = mkOption {
- type = str;
- };
-
- ssd = mkOption {
- type = bool;
- };
-
- snapper = mkOption {
- type = nullOr str;
- default = null;
- };
- };
- });
- };
};
- config = {
- environment.systemPackages = optional (cfg.snapperSubvols != { }) pkgs.local.btclone;
-
- fileSystems =
- let
- inherit (cfg) fs;
- btrfs = { device, subvol, ssd, ... }: {
- inherit device;
- fsType = "btrfs";
- options = [ "noatime" "compress=zstd" "subvol=${subvol}" ] ++ optional ssd "ssd";
- };
- in
- mapAttrs (_: btrfs) cfg.fs.btrfs;
-
- local.snapperSubvols =
- let
- snapperEntry = path: opts: { name = opts.snapper; value = path; };
- validEntry = _: opts: opts.snapper != null;
- in
- mapAttrs' snapperEntry (filterAttrs validEntry cfg.fs.btrfs);
+ config = mkIf (cfg.snapper != { }) {
+ environment.systemPackages = [ pkgs.local.btclone ];
services.snapper.configs =
let
@@ -111,6 +68,6 @@ in
EMPTY_PRE_POST_MIN_AGE = "1800";
};
in
- mapAttrs snapperConfig cfg.snapperSubvols;
+ mapAttrs snapperConfig cfg.snapper;
};
}