From 7970c36801aa5ab4cc90118381c40e44c5e36343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 29 Jul 2024 16:11:01 +0300 Subject: [PATCH] btrfssnapshot: make it somewhat work --- hosts/mtworx/configuration.nix | 16 ++++++++++++++++ modules/base/default.nix | 1 - .../{base => services}/btrfssnapshot/default.nix | 12 ++++++------ modules/services/default.nix | 1 + shared/home/vimrc | 3 +++ 5 files changed, 26 insertions(+), 7 deletions(-) rename modules/{base => services}/btrfssnapshot/default.nix (79%) diff --git a/hosts/mtworx/configuration.nix b/hosts/mtworx/configuration.nix index 0eefe5a..32ad30d 100644 --- a/hosts/mtworx/configuration.nix +++ b/hosts/mtworx/configuration.nix @@ -79,6 +79,22 @@ in verboseLogs = true; }; + btrfssnapshot = { + enable = true; + subvolumes = { + "/home" = { + label = "5minutely"; + keep = 12; + refreshInterval = "*:0/5"; + }; + #"/home" = { + # label = "hourly"; + # keep = 24; + # refreshInterval = "*:00:00"; + #}; + }; + }; + wifibackup = { enable = true; toPath = "/home/${config.mj.username}/M-Active/.wifi"; diff --git a/modules/base/default.nix b/modules/base/default.nix index 71c5229..4e5fdef 100644 --- a/modules/base/default.nix +++ b/modules/base/default.nix @@ -11,7 +11,6 @@ in { imports = [ ./boot - ./btrfssnapshot ./fileSystems ./snapshot ./sshd diff --git a/modules/base/btrfssnapshot/default.nix b/modules/services/btrfssnapshot/default.nix similarity index 79% rename from modules/base/btrfssnapshot/default.nix rename to modules/services/btrfssnapshot/default.nix index 52433d9..8a888a4 100644 --- a/modules/base/btrfssnapshot/default.nix +++ b/modules/services/btrfssnapshot/default.nix @@ -5,10 +5,10 @@ ... }: let - cfg = config.mj.base.btrfssnapshot; + cfg = config.mj.services.btrfssnapshot; in { - options.mj.base.btrfssnapshot = { + options.mj.services.btrfssnapshot = { enable = lib.mkEnableOption "Enable btrfs snapshots"; subvolumes = lib.mkOption { @@ -30,10 +30,10 @@ in services = lib.mapAttrs' ( subvolume: params: lib.nameValuePair "btrfs-snapshot-${lib.strings.sanitizeDerivationName subvolume}" { - description = "${params.label} btrfs snapshot for ${subvolume} (keep ${params.keep}"; - serviceConfig.ExecStart = "${pkgs.btrfs-auto-snapshot} --verbose --label=${params.label} --keep=${params.keep} ${subvolume}"; + description = "${params.label} btrfs snapshot for ${subvolume} (keep ${builtins.toString params.keep})"; + serviceConfig.ExecStart = "${pkgs.btrfs-auto-snapshot}/bin/btrfs-auto-snapshot --verbose --label=${params.label} --keep=${builtins.toString params.keep} ${subvolume}"; } - ); + ) cfg.subvolumes; timers = lib.mapAttrs' ( subvolume: params: @@ -42,7 +42,7 @@ in wantedBy = [ "timers.target" ]; timerConfig.OnCalendar = params.refreshInterval; } - ); + ) cfg.subvolumes; }; }; } diff --git a/modules/services/default.nix b/modules/services/default.nix index b6b315a..157161e 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -2,6 +2,7 @@ { imports = [ ./borgstor + ./btrfssnapshot ./deployerbot ./friendlyport ./gitea diff --git a/shared/home/vimrc b/shared/home/vimrc index 9f60d95..8d2986c 100644 --- a/shared/home/vimrc +++ b/shared/home/vimrc @@ -61,6 +61,9 @@ au FileType yaml setlocal ts=2 sw=2 sts=2 au FileType sql setlocal formatprg=pg_format\ - au FileType sql setlocal ts=2 sw=2 sts=2 +" nix +au FileType nix setlocal ts=2 sw=2 sts=2 + " mail autocmd BufRead,BufNewFile *mutt-* setfiletype mail