{ config, lib, pkgs, ... }:
with lib; {

  services.syncthing = {
    guiAddress = lib.mkDefault "${config.networking.hostName}.private:8384";
    overrideDevices = lib.mkDefault true;
    settings.devices =
      let
        device = name: id: {
          "${name}" = {
            name = name;
            id = id;
            addresses = [ "tcp://${name}.private:22000" ];
          };
        };
      in
      {
        "robi" = {
          name = "robi";
          id = "B6P22RF-5BC2LTZ-6GHVWRZ-5D3OLXC-D66E45Y-JEB3WYT-ZQ442WZ-5FFAMQ7";
          addresses = [ "tcp://144.76.13.147:22000" ];
        };
        "orbi" = {
          name = "orbi";
          id = "5U5ZP6R-SUQO5SY-WICWWLZ-HPHQBM5-P27YSU6-66TWIBK-XLX4X5N-4O6TVAC";
          addresses = [ "tcp://95.216.66.212:22000" ];
        };
      }
      // (device "mobi" "NGI7UN6-MR2YPYI-L7DGN3I-JFZU2N3-RJBJV6K-2VZVQSJ-PWLZYOK-PXZYRAF")
      // (device "bobi" "FOJ3D27-W5OJMQR-7S77A3V-AS5BCG2-CIGWVMP-UBSVQNN-QZLHAIZ-IO7GKAE")
      // (device "cream" "MQVKATH-THTPET5-KYAT7XX-BOIIIBA-P7OOF7Y-IWAUN53-S2VNVOY-BZWTGQK")
      // (device "cherry" "WX2HZQ7-WAOL6YR-QJYFS2L-SVUJQB4-SKHZHVE-J7XCWLQ-6GRATXX-VJUMOAH")
      // (device "chungus" "GZGW2YW-6RRUPDN-LFAOATC-56FS7LH-YC7R32N-LVA5JUX-3LSBYOX-BFR67QZ")
      // (device "iPhone" "APFS6SA-VVTARXU-3WHHRZG-TE5N3T4-X4IC76V-T67EKZ6-NLGP3TW-EZYXYAH")
      // (device "iPad" "JDDNVYD-H3WMSSS-WZ745KL-7QEGN6O-ZSGQLQU-YBR2L42-7FO7KJ4-BXPYDA5")
      // {
        bumba = {
          name = "windows-bumba";
          id = "JS7PWTO-VKFGBUP-GNFLSWP-MGFJ2KH-HLO2LKW-V3RPCR6-PCB5SQC-42FCKQZ";
        };
      }
      // {
        mors = {
          name = "lassulus-mors";
          id = "ZPRS57K-YK32ROQ-7A6MRAV-VOYXQ3I-CQCXISZ-C5PCV2A-GSFLG3I-K7UGGAH";
          addresses = [ "tcp://mors.r:22000" ];
        };
      };

    settings.folders = {

      # needs to be on encrypted drives
      # -------------------------------
      oscar_cpap = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/oscar_cpap";
        devices = [ "chungus" "cream" "cherry" ];
      };
      audiobooks = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/audiobooks";
        devices = [ "chungus" "orbi" ];
      };
      logseq = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/logseq";
        devices = [ "chungus" "cream" "cherry" "iPhone" "iPad" ];
      };
      lectures = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/lectures";
        devices = [ "chungus" "orbi" ];
      };
      books = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/books";
        devices = [ "chungus" "robi" "cream" "cherry" ];
        versioning = {
          type = "simple";
          params.keep = "2";
        };
      };
      password-store = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/password-store";
        devices = [ "chungus" "cream" "mobi" "bobi" "cherry" ];
        versioning = {
          type = "simple";
          params.keep = "10";
        };
      };
      desktop = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/desktop";
        devices = [ "chungus" "cream" "mobi" "bobi" "cherry" ];
      };
      finance = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/finance";
        devices = [ "chungus" "cream" "mobi" "bobi" ];
        versioning = {
          type = "simple";
          params.keep = "10";
        };
      };
      # todo remove if zfs is is used
      nextcloud_backup = {
        enable = lib.mkDefault false;
        path = lib.mkDefault "/tmp/lost-fotos";
        devices = [ "chungus" "robi" ];
        versioning = {
          type = "simple";
          params.keep = "2";
        };
      };
    };
  };

}