fork/home-manager
git clone https://git.julia.blue/fork/home-manager
d4a5076e
master
1{ config , pkgs , ...} : 2 3let 4 5backups = config . programs . borgmatic . backups ; 6excludeFile = builtins . toFile "excludeFile.txt" "/foo/bar" ; 7 8in { 9programs . borgmatic = { 10enable = true ; 11backups = { 12main = { 13location = { 14sourceDirectories = [ "/my-stuff-to-backup" ]; 15repositories = [ "/mnt/disk1" ]; 16excludeHomeManagerSymlinks = true ; 17extraConfig = { exclude_from = [ ( toString excludeFile ) ]; }; 18}; 19}; 20}; 21}; 22 23test . stubs . borgmatic = { }; 24 25nmt . script = '' 26config_file = $ TESTED /home-files/.config/borgmatic.d/main.yaml 27assertFileExists $ config_file 28 29declare -A expectations 30 31expectations [exclude_from[0]]= " ${ excludeFile } " 32 33yq= ${ pkgs . yq-go } /bin/yq 34 35for filter in "'' $ { !expectations[@]} "; do 36expected_value="'' $ { expectations [ $ filter ]}" 37actual_value=" $( $ yq ". $ filter " $ config_file ) " 38 39if [[ " $ actual_value " != " $ expected_value " ]]; then 40fail " Expected '$filter' to be '$expected_value' but was '$actual_value'" 41fi 42done 43 44hmExclusionsFile= $( $ yq '.exclude_from[1]' $ config_file ) 45expected_content='/home/hm-user/.config/borgmatic.d/main.yaml' 46 47grep --quiet " $ expected_content " " $ hmExclusionsFile " 48 49if [[ $ ? -ne 0 ]]; then 50echo "Expected to find $ expected_content in file $ hmExclusionsFile but didn't" >&2 51exit 1 52fi 53'' ; 54}