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

@ -152,29 +152,22 @@ let
hmExcludeFile = pkgs.writeText "hm-symlinks.txt" hmExcludePatterns;
writeConfig = config:
generators.toYAML { } {
location = removeNullValues {
source_directories = config.location.sourceDirectories;
repositories = config.location.repositories;
} // config.location.extraConfig;
storage = removeNullValues {
encryption_passcommand = config.storage.encryptionPasscommand;
} // config.storage.extraConfig;
retention = removeNullValues {
keep_within = config.retention.keepWithin;
keep_secondly = config.retention.keepSecondly;
keep_minutely = config.retention.keepMinutely;
keep_hourly = config.retention.keepHourly;
keep_daily = config.retention.keepDaily;
keep_weekly = config.retention.keepWeekly;
keep_monthly = config.retention.keepMonthly;
keep_yearly = config.retention.keepYearly;
} // config.retention.extraConfig;
consistency = removeNullValues { checks = config.consistency.checks; }
// config.consistency.extraConfig;
output = config.output.extraConfig;
hooks = config.hooks.extraConfig;
};
generators.toYAML { } (removeNullValues ({
source_directories = config.location.sourceDirectories;
repositories = config.location.repositories;
encryption_passcommand = config.storage.encryptionPasscommand;
keep_within = config.retention.keepWithin;
keep_secondly = config.retention.keepSecondly;
keep_minutely = config.retention.keepMinutely;
keep_hourly = config.retention.keepHourly;
keep_daily = config.retention.keepDaily;
keep_weekly = config.retention.keepWeekly;
keep_monthly = config.retention.keepMonthly;
keep_yearly = config.retention.keepYearly;
checks = config.consistency.checks;
} // config.location.extraConfig // config.storage.extraConfig
// config.retention.extraConfig // config.consistency.extraConfig
// config.output.extraConfig // config.hooks.extraConfig));
in {
meta.maintainers = [ maintainers.DamienCassou ];