mirror of
https://github.com/nix-community/home-manager
synced 2024-11-09 04:39:44 +01:00
d4a5076ea8
The configuration file format of borgmatic has changed in version 1.8.0: https://projects.torsion.org/borgmatic-collective/borgmatic/src/branch/main/NEWS This commit makes Home Manager generate borgmatic's configuration file using the new format. Even though the NEWS file indicates that old configuration files are compatible, this is not 100% the case: empty sections work fine in old borgmatic but stop working in new ones. I've reported the bug upstream by email as I couldn't create an account on the forge.
54 lines
1.4 KiB
Nix
54 lines
1.4 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
let
|
|
|
|
backups = config.programs.borgmatic.backups;
|
|
excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
|
|
|
|
in {
|
|
programs.borgmatic = {
|
|
enable = true;
|
|
backups = {
|
|
main = {
|
|
location = {
|
|
sourceDirectories = [ "/my-stuff-to-backup" ];
|
|
repositories = [ "/mnt/disk1" ];
|
|
excludeHomeManagerSymlinks = true;
|
|
extraConfig = { exclude_from = [ (toString excludeFile) ]; };
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
test.stubs.borgmatic = { };
|
|
|
|
nmt.script = ''
|
|
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
|
|
assertFileExists $config_file
|
|
|
|
declare -A expectations
|
|
|
|
expectations[exclude_from[0]]="${excludeFile}"
|
|
|
|
yq=${pkgs.yq-go}/bin/yq
|
|
|
|
for filter in "''${!expectations[@]}"; do
|
|
expected_value="''${expectations[$filter]}"
|
|
actual_value="$($yq ".$filter" $config_file)"
|
|
|
|
if [[ "$actual_value" != "$expected_value" ]]; then
|
|
fail "Expected '$filter' to be '$expected_value' but was '$actual_value'"
|
|
fi
|
|
done
|
|
|
|
hmExclusionsFile=$($yq '.exclude_from[1]' $config_file)
|
|
expected_content='/home/hm-user/.config/borgmatic.d/main.yaml'
|
|
|
|
grep --quiet "$expected_content" "$hmExclusionsFile"
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "Expected to find $expected_content in file $hmExclusionsFile but didn't" >&2
|
|
exit 1
|
|
fi
|
|
'';
|
|
}
|