Skip to content

Commit

Permalink
nix: create btrfs snapshot systemd service
Browse files Browse the repository at this point in the history
  • Loading branch information
benmezger committed Feb 9, 2025
1 parent 1cb323e commit e956b57
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions hosts/default/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
fwupd.enable = true;
thunar.enable = true;
syncmail.enable = true;
btrfsSnapshot.enable = true;
};

time.timeZone = userConf.timezone;
Expand Down
38 changes: 38 additions & 0 deletions modules/linux/btrfs-snapshot.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
config,
lib,
pkgs,
userConf,
...
}:

let
cfg = config.my.btrfsSnapshot;
in
{
options.my = {
btrfsSnapshot.enable = lib.mkEnableOption "enable btrfs snapshot service";
};

config = lib.mkIf cfg.enable {
systemd.services."btrfs-snapshot" = {
enable = true;
wantedBy = [ "multi-user.target" ];
description = "Start btrfs-snapshot script.";
serviceConfig = {
Type = "oneshot";
ExecStart = ''${pkgs.bash}/bin/bash -c btrfs-snapshot'';
};
};

systemd.timers."btrfs-snapshot" = {
enable = true;
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "2m";
OnUnitActiveSec = "6h";
Unit = "btrfs-snapshot.service";
};
};
};
}
1 change: 1 addition & 0 deletions modules/linux/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
./fwupd.nix
./thunar.nix
./syncmail.nix
./btrfs-snapshot.nix
];
}

0 comments on commit e956b57

Please sign in to comment.