{ config, lib, pkgs, ... }: { options = { programs.rclone = { enable = lib.mkEnableOption "rclone"; }; }; config = let cfg = config.programs.rclone; in { home.packages = lib.optional cfg.enable pkgs.rclone; systemd.user = lib.optionalAttrs cfg.enable { enable = true; services = { rclone = { Unit = { Description = "rclone Starter"; Documentation = "man:rclone(1)"; }; Service = { Type = "simple"; ExecStartPre = let script = pkgs.writeShellScriptBin "rclone-pre" '' sleep 10 ''; in (lib.getExe script); ExecStart = let script = pkgs.writeShellScriptBin "rclone" '' systemctl --user start rclone.target ''; in (lib.getExe script); }; }; }; targets.rclone = { Unit = { Description = "rclone Mounts"; Documentation = "man:rclone(1)"; }; }; }; }; }