fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Damien Cassouborgmatic: improve support for version 1.8.0d4a5076e

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