Modularize nextcloud and remove need for GUI application

This commit is contained in:
DashieTM 2024-08-04 03:48:07 +02:00
parent 8d35835f89
commit ee2b51bbc1
6 changed files with 74 additions and 47 deletions

View file

@ -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
View 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;
};
}