{self, ...}: {
flake.nixosModules.kdrive-laptop = {pkgs-unstable, ...}: {
environment.systemPackages = with pkgs-unstable; [
rclone
self.packages.${pkgs.system}.custom-checkKdrive
self.packages.${pkgs.system}.custom-mountkdrive-laptop
];
# removes rclone error
programs.fuse = {
userAllowOther = true;
enable = true;
};
};
flake.nixosModules.kdrive-desktop = {pkgs, ...}: {
environment.systemPackages = [
pkgs.rclone
self.packages.${pkgs.system}.custom-checkKdrive
self.packages.${pkgs.system}.custom-synckdrive-desktop
];
# removes rclone error
programs.fuse = {
userAllowOther = true;
enable = true;
};
systemd.user.services.kdrive-sync = {
serviceConfig = {
ExecStart = "${self.packages.${pkgs.system}.custom-synckdrive-desktop}/bin/custom-synckdrive";
Nice = 19; # lowest CPU scheduling priority
IOSchedulingClass = "idle";
IOSchedulingPriority = 7;
# Optional:
CPUWeight = 1; # minimum relative CPU share
};
};
systemd.user.timers.kdrive-sync = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "10m";
OnUnitActiveSec = "1h";
};
};
};
perSystem = {pkgs, ...}: {
packages.custom-checkKdrive = pkgs.writeShellApplication {
name = "custom-checkKdrive";
runtimeInputs = with pkgs; [
rclone
matrix-commander-rs
libnotify
];
text = ''
# waits for an internet connection. It pings both Google DNS and Cloudfare dns in case one of them is down
until ping -c1 -W1 1.1.1.1 >/dev/null 2>&1 || \
ping -c1 -W1 8.8.8.8 >/dev/null 2>&1
do
sleep 1
done
set +e
output=$(rclone lsd kdrive: 2>&1)
status=$?
set -e
if [ $status -eq 0 ]; then
echo "kdrive OK"
else
echo "kdrive rclone failed with error: $output"
notify-send "rclone kdrive failed" "$output"
matrix-commander-rs --verbose -m "rclone kdrive failed.
Error:
$output