borgmatic: improve support for version 1.8.0

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.
This commit is contained in:
Damien Cassou 2023-10-15 00:38:55 +02:00 committed by GitHub
parent 9a2ce65697
commit d4a5076ea8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 47 deletions

View file

@ -62,50 +62,48 @@ in {
declare -A expectations
expectations[location.source_directories[0]]="${
expectations[source_directories[0]]="${
builtins.elemAt backups.main.location.sourceDirectories 0
}"
expectations[location.repositories[0]]="${
expectations[repositories[0]]="${
builtins.elemAt backups.main.location.repositories 0
}"
expectations[location.repositories[1]]="${
expectations[repositories[1]]="${
builtins.elemAt backups.main.location.repositories 1
}"
expectations[location.one_file_system]="${
expectations[one_file_system]="${
boolToString backups.main.location.extraConfig.one_file_system
}"
expectations[location.exclude_patterns[0]]="${
expectations[exclude_patterns[0]]="${
builtins.elemAt backups.main.location.extraConfig.exclude_patterns 0
}"
expectations[storage.encryption_passcommand]="${backups.main.storage.encryptionPasscommand}"
expectations[storage.checkpoint_interval]="${
expectations[encryption_passcommand]="${backups.main.storage.encryptionPasscommand}"
expectations[checkpoint_interval]="${
toString backups.main.storage.extraConfig.checkpoint_interval
}"
expectations[retention.keep_within]="${backups.main.retention.keepWithin}"
expectations[retention.keep_secondly]="${
expectations[keep_within]="${backups.main.retention.keepWithin}"
expectations[keep_secondly]="${
toString backups.main.retention.keepSecondly
}"
expectations[retention.prefix]="${backups.main.retention.extraConfig.prefix}"
expectations[prefix]="${backups.main.retention.extraConfig.prefix}"
expectations[consistency.checks[0].name]="${
expectations[checks[0].name]="${
(builtins.elemAt backups.main.consistency.checks 0).name
}"
expectations[consistency.checks[0].frequency]="${
expectations[checks[0].frequency]="${
(builtins.elemAt backups.main.consistency.checks 0).frequency
}"
expectations[consistency.checks[1].name]="${
expectations[checks[1].name]="${
(builtins.elemAt backups.main.consistency.checks 1).name
}"
expectations[consistency.checks[1].frequency]="${
expectations[checks[1].frequency]="${
(builtins.elemAt backups.main.consistency.checks 1).frequency
}"
expectations[consistency.prefix]="${backups.main.consistency.extraConfig.prefix}"
expectations[output.color]="${
boolToString backups.main.output.extraConfig.color
}"
expectations[hooks.before_actions[0]]="${
expectations[prefix]="${backups.main.consistency.extraConfig.prefix}"
expectations[color]="${boolToString backups.main.output.extraConfig.color}"
expectations[before_actions[0]]="${
builtins.elemAt backups.main.hooks.extraConfig.before_actions 0
}"
@ -120,7 +118,7 @@ in {
fi
done
one_file_system=$($yq ".location.one_file_system" $config_file)
one_file_system=$($yq ".one_file_system" $config_file)
if [[ $one_file_system != "true" ]]; then
fail "Expected one_file_system to be true but it was $one_file_system"
fi

View file

@ -27,7 +27,7 @@ in {
yq=${pkgs.yq-go}/bin/yq
hmExclusionsFile=$($yq '.location.exclude_from[0]' $config_file)
hmExclusionsFile=$($yq '.exclude_from[0]' $config_file)
expected_content='/home/hm-user/.config/borgmatic.d/main.yaml'
grep --quiet "$expected_content" "$hmExclusionsFile"

View file

@ -28,7 +28,7 @@ in {
declare -A expectations
expectations[location.exclude_from[0]]="${excludeFile}"
expectations[exclude_from[0]]="${excludeFile}"
yq=${pkgs.yq-go}/bin/yq
@ -41,7 +41,7 @@ in {
fi
done
hmExclusionsFile=$($yq '.location.exclude_from[1]' $config_file)
hmExclusionsFile=$($yq '.exclude_from[1]' $config_file)
expected_content='/home/hm-user/.config/borgmatic.d/main.yaml'
grep --quiet "$expected_content" "$hmExclusionsFile"

View file

@ -28,7 +28,7 @@ in {
declare -A expectations
expectations[location.exclude_from[0]]="${excludeFile}"
expectations[exclude_from[0]]="${excludeFile}"
yq=${pkgs.yq-go}/bin/yq