summaryrefslogtreecommitdiff
path: root/modules/borgbackup/btrfs-snapshots.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-02-06 21:20:24 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-02-06 21:20:24 +0100
commit32282ae39d352428988891207fb4f276a311846a (patch)
tree03b3e562996b5c47b29fbc43beae72801fc66844 /modules/borgbackup/btrfs-snapshots.nix
parentab822140ffb2980ced0026bbd6e4f417b53451b0 (diff)
downloadnixos-32282ae39d352428988891207fb4f276a311846a.tar
nixos-32282ae39d352428988891207fb4f276a311846a.tar.gz
nixos-32282ae39d352428988891207fb4f276a311846a.tar.bz2
nixos-32282ae39d352428988891207fb4f276a311846a.tar.xz
nixos-32282ae39d352428988891207fb4f276a311846a.zip
vidhar: borg
Diffstat (limited to 'modules/borgbackup/btrfs-snapshots.nix')
-rw-r--r--modules/borgbackup/btrfs-snapshots.nix52
1 files changed, 0 insertions, 52 deletions
diff --git a/modules/borgbackup/btrfs-snapshots.nix b/modules/borgbackup/btrfs-snapshots.nix
deleted file mode 100644
index 96d2b2ba..00000000
--- a/modules/borgbackup/btrfs-snapshots.nix
+++ /dev/null
@@ -1,52 +0,0 @@
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.btrfs-snapshots;
7
8 snapshotMount = str: "${str}${cfg.mountSuffix}";
9in {
10 options = {
11
12 services.btrfs-snapshots = {
13 enable = mkEnableOption "a systemd unit for btrfs snapshots";
14
15 mountSuffix = mkOption {
16 type = types.str;
17 default = ".snapshot";
18 };
19
20 readOnly = mkOption {
21 type = types.bool;
22 default = true;
23 };
24
25 persist = mkOption {
26 type = types.bool;
27 default = false;
28 };
29 };
30
31 };
32
33
34 config = mkIf cfg.enable {
35 systemd.services."btrfs-snapshot@" = {
36 enable = true;
37
38 unitConfig = {
39 StopWhenUnneeded = !cfg.persist;
40 };
41
42 serviceConfig = with pkgs; {
43 Type = "oneshot";
44 ExecStartPre = "-${btrfs-progs}/bin/btrfs subvolume delete -c ${snapshotMount "%f"}";
45 ExecStart = "${btrfs-progs}/bin/btrfs subvolume snapshot ${optionalString cfg.readOnly "-r"} %f ${snapshotMount "%f"}";
46 RemainAfterExit = true;
47 ExecStop = "${btrfs-progs}/bin/btrfs subvolume delete -c ${snapshotMount "%f"}";
48 };
49 };
50
51 };
52}