aboutsummaryrefslogtreecommitdiff
path: root/modules/nextcloud.nix
blob: 6e8774f1c5804902d7434306efe4a732fad39a7f (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
{ config, lib, pkgs, ... }:

let
  cfg = config.nextcloud;
in {
  options.nextcloud.enable = lib.mkEnableOption "Enable nextcloud and setup";
  config = lib.mkIf cfg.enable {
    home.file.".netrc".text = ''default
      login exmaple
      password test123
    '';

    home.packages = pkgs.nextcloud-client;

    systemd.user = {
      services.nextcloud-autosync = {
        Unit = {
          Description = "Auto sync Nextcloud";
          After = "network-online.target";
        };
        Service = {
          Type = "simple";
          ExecStart = "${pkgs.nextcloud-client}/bin/nextcloudcmd -h -n https://cloud.schererleander.de";
          TimeoutStopSec = "180";
          KillMode = "process";
          KillSignal = "SIGINT";
        };
        Install.WantedBy = ["multi-user.target"];
      };
      timers.nextcloud-autosync = {
        Unit.Description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes";
        Timer.OnBootSec = "5min";
        Timer.OnUnitActiveSec = "60min";
        Install.WantedBy = ["multi-user.target" "timers.target"];
      };
      startServices = true;
    };
  };
}