1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-10 02:51:05 +01:00
home-manager/tests/modules/programs/borgmatic/exclude-hm-symlinks.nix
Austin Horstman cba2f9ce95 treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
2025-04-08 08:50:05 -07:00

54 lines
1.3 KiB
Nix

{ 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 = true;
extraConfig = {
exclude_from = [ (toString excludeFile) ];
};
};
};
};
};
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
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
'';
}