mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 15:11:34 +01:00
Add nextcloud synchronization
This commit is contained in:
parent
9a6056f51b
commit
dc295a9e49
7 changed files with 68 additions and 20 deletions
59
modules/home/nextcloud-sync.nix
Normal file
59
modules/home/nextcloud-sync.nix
Normal 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"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue