Files
home-manager/tests/modules/programs/borgmatic/include-hm-symlinks.nix
Austin Horstman 7d46509d83 borgmatic: migrate backups to native settings
Add programs.borgmatic.backups.<name>.settings for native borgmatic
YAML and generate each backup file from it.

The location, storage, retention, and consistency options and the
section extraConfig options become deprecated aliases into settings.
Warnings name the affected backup. Legacy configurations without
overlapping keys produce the same YAML, and Home Manager symlink
exclusions still append to exclude_from.

Drop the assertions that rejected backups setting both or neither of
sourceDirectories and patterns, so native source patterns and
database-only backups work.
2026-09-30 07:59:27 -05:00

62 lines
1.4 KiB
Nix

{ lib, realPkgs, ... }:
let
excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in
{
programs.borgmatic = {
enable = true;
backups = {
main = {
location = {
sourceDirectories = [ "/my-stuff-to-backup" ];
repositories = [ "/mnt/disk1" ];
excludeHomeManagerSymlinks = false;
extraConfig = {
exclude_from = [ (toString excludeFile) ];
};
};
};
};
};
test.asserts.warnings.expected = (import ./warnings.nix { inherit lib; }) {
file = ./include-hm-symlinks.nix;
entries = [
{ from = "location.extraConfig"; }
{
from = "location.repositories";
to = "settings.repositories";
changed = true;
}
{
from = "location.sourceDirectories";
to = "settings.source_directories";
}
];
};
nmt.script = ''
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
assertFileExists $config_file
declare -A expectations
expectations[exclude_from[0]]="${excludeFile}"
yq=${realPkgs.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
'';
}