From cb0e49e5d6de90f7939a0452db52526b72bae269 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Thu, 30 Mar 2023 15:40:02 -0500 Subject: [PATCH] add pre/post command --- flake.nix | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index f7f6387..8480ac7 100644 --- a/flake.nix +++ b/flake.nix @@ -19,8 +19,6 @@ arch = { "x86_64-linux" = "amd64"; }.${system}; - - in { packages = { }; @@ -109,6 +107,14 @@ paths = lib.options.mkOption { type = lib.types.listOf lib.types.str; }; + preCommand = lib.options.mkOption { + type = lib.types.lines; + default = ""; + }; + postCommand = lib.options.mkOption { + type = lib.types.lines; + default = ""; + }; }; } ); @@ -160,20 +166,10 @@ AZURE_ACCOUNT_KEY=${cfg.azure.account_key} ''; }.${cfg.storage}; - # if cfg.storage == "b2" - # then - # else - # ""; repositoryConfig = { "b2" = "b2:${bucket}:${directory}"; "azure" = "azure:${bucket}:${directory}"; }.${cfg.storage}; - - # if cfg.storage == "b2" - # then - # "b2:${cfg.b2.bucket}:${config.networking.hostName}.${config.networking.domain}" - # else - # ""; in { text = '' @@ -270,7 +266,13 @@ backup.excludes; paths = lib.strings.concatStringsSep " " backup.paths; in - "${pkgs.restic}/bin/restic backup${one-file-system}${excludes} ${paths}" + '' + ${backup.preCommand} + + ${pkgs.restic}/bin/restic backup${one-file-system}${excludes} ${paths} + + ${backup.postCommand} + '' ) cfg.backups );