Modularize nextcloud and remove need for GUI application
This commit is contained in:
parent
8d35835f89
commit
ee2b51bbc1
6 changed files with 74 additions and 47 deletions
|
|
@ -37,6 +37,7 @@ in
|
|||
./oxi/default.nix
|
||||
./themes/default.nix
|
||||
./individual_configs/default.nix
|
||||
./sync.nix
|
||||
] ++ base_imports
|
||||
++ lib.optional (builtins.pathExists mod) mod;
|
||||
};
|
||||
|
|
|
|||
48
programs/sync.nix
Normal file
48
programs/sync.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{ config, pkgs, options, lib, ... }:
|
||||
let
|
||||
username = config.mods.nextcloud.username;
|
||||
password = config.sops.secrets.nextcloud.path;
|
||||
url = config.mods.nextcloud.url;
|
||||
synclist = config.mods.nextcloud.synclist;
|
||||
in
|
||||
lib.mkIf config.mods.nextcloud.enable {
|
||||
systemd.user = {
|
||||
services =
|
||||
(builtins.listToAttrs
|
||||
(map
|
||||
(opts: {
|
||||
name = "${opts.name}";
|
||||
value = {
|
||||
Unit = {
|
||||
Description = "Auto sync Nextcloud";
|
||||
After = "network-online.target";
|
||||
};
|
||||
Service = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.nextcloud-client}/bin/nextcloudcmd -h --path ${opts.remote} ${opts.local} https://${username}:$(bat ${password})@${url}";
|
||||
TimeoutStopSec = "180";
|
||||
KillMode = "process";
|
||||
KillSignal = "SIGINT";
|
||||
};
|
||||
Install.WantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
})
|
||||
synclist
|
||||
));
|
||||
timers =
|
||||
(builtins.listToAttrs
|
||||
(map
|
||||
(opts: {
|
||||
name = "${opts.name}";
|
||||
value = {
|
||||
Unit.Description = "Automatic sync files with Nextcloud when booted up after 1 minute then rerun every 60 minutes";
|
||||
Timer.OnBootSec = "1min";
|
||||
Timer.OnUnitActiveSec = "60min";
|
||||
Install.WantedBy = [ "multi-user.target" "timers.target" ];
|
||||
};
|
||||
})
|
||||
synclist
|
||||
));
|
||||
startServices = true;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue