2023-03-19 10:28:02 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2023-05-12 22:08:12 +00:00
|
|
|
|
2023-03-19 10:28:02 +00:00
|
|
|
backups = config.programs.borgmatic.backups;
|
2023-05-12 22:08:12 +00:00
|
|
|
excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
|
|
|
|
|
2023-03-19 10:28:02 +00:00
|
|
|
in {
|
2023-05-12 22:08:12 +00:00
|
|
|
programs.borgmatic = {
|
|
|
|
enable = true;
|
|
|
|
backups = {
|
|
|
|
main = {
|
|
|
|
location = {
|
|
|
|
sourceDirectories = [ "/my-stuff-to-backup" ];
|
|
|
|
repositories = [ "/mnt/disk1" ];
|
|
|
|
excludeHomeManagerSymlinks = true;
|
2023-03-19 10:28:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-05-12 22:08:12 +00:00
|
|
|
};
|
2023-03-19 10:28:02 +00:00
|
|
|
|
2023-05-12 22:08:12 +00:00
|
|
|
test.stubs.borgmatic = { };
|
2023-03-19 10:28:02 +00:00
|
|
|
|
2023-05-12 22:08:12 +00:00
|
|
|
nmt.script = ''
|
|
|
|
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
|
|
|
|
assertFileExists $config_file
|
2023-03-19 10:28:02 +00:00
|
|
|
|
2023-05-12 22:08:12 +00:00
|
|
|
yq=${pkgs.yq-go}/bin/yq
|
2023-03-19 10:28:02 +00:00
|
|
|
|
2023-05-12 22:08:12 +00:00
|
|
|
hmExclusionsFile=$($yq '.location.exclude_from[0]' $config_file)
|
|
|
|
expected_content='/home/hm-user/.config/borgmatic.d/main.yaml'
|
2023-03-19 10:28:02 +00:00
|
|
|
|
2023-05-12 22:08:12 +00:00
|
|
|
grep --quiet "$expected_content" "$hmExclusionsFile"
|
2023-03-19 10:28:02 +00:00
|
|
|
|
2023-05-12 22:08:12 +00:00
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
echo "Expected to find $expected_content in file $hmExclusionsFile but didn't" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
2023-03-19 10:28:02 +00:00
|
|
|
}
|