Add nextcloud synchronization

This commit is contained in:
SebastianStork 2024-10-20 13:06:13 +02:00
parent 9a6056f51b
commit dc295a9e49
7 changed files with 68 additions and 20 deletions

View file

@ -0,0 +1,59 @@
{
config,
pkgs,
lib,
...
}:
let
paths = [
"Documents"
"Downloads"
"Pictures"
"Music"
"Videos"
"Projects"
];
syncCommand =
path:
"nextcloudcmd ${
lib.concatStringsSep " " [
"--user seb"
"--password \"$(cat ${config.sops.secrets."nextcloud-password".path})\""
"--path /Sync/${path}"
"--non-interactive"
"~/${path}"
"https://cloud.stork-atlas.ts.net"
]
}";
in
{
options.myConfig.nextcloud-sync.enable = lib.mkEnableOption "";
config = lib.mkIf config.myConfig.nextcloud-sync.enable {
sops.secrets."nextcloud-password" = { };
systemd.user = {
services.nextcloud-autosync = {
Service = {
ExecStart = lib.getExe' (pkgs.writeShellApplication {
name = "nextcloud-sync-script";
runtimeInputs = [ pkgs.nextcloud-client ];
text = builtins.concatStringsSep "\n" (map syncCommand paths);
}) "nextcloud-sync-script";
};
};
timers.nextcloud-autosync = {
Install.WantedBy = [ "default.target" ];
Timer = {
OnBootSec = "1min";
OnUnitActiveSec = "5min";
};
Unit.After = [
"network-online.target"
"sops-nix.service"
];
};
};
};
}

View file

@ -1,11 +0,0 @@
{ config, lib, ... }:
{
options.myConfig.nextcloud.enable = lib.mkEnableOption "";
config = lib.mkIf config.myConfig.nextcloud.enable {
services.nextcloud-client = {
enable = true;
startInBackground = true;
};
};
}