summaryrefslogtreecommitdiffstats
path: root/lass/2configs/muchsync.nix
blob: b6d8c5dbc432f9d88e0ab87e68f66ed953aabe47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
with (import <stockholm/lib>);
{ config, pkgs, ... }:

{
  systemd.services.muchsync = let
    hosts = [
      "coaxmetal.r"
      "mors.r"
      "green.r"
    ];
  in {
    description = "sync mails";
    environment = {
      NOTMUCH_CONFIG = config.environment.variables.NOTMUCH_CONFIG;
    };
    after = [ "network.target" ];

    restartIfChanged = false;

    path = [
      pkgs.notmuch
      pkgs.openssh
    ];

    startAt = "*:*"; # run every minute
    serviceConfig = {
      User = "lass";
      Type = "oneshot";
      ExecStart = pkgs.writeDash "sync-mails" ''
        set -euf

        /run/current-system/sw/bin/nm-tag-init 2>/dev/null
        ${concatMapStringsSep "\n" (host: ''
          echo syncing ${host}:
          ${pkgs.muchsync}/bin/muchsync -s 'ssh -CTaxq -o ConnectTimeout=4' --nonew lass@${host} || :
        '') hosts}
      '';
    };
  };
}