Add a module for creating rclone
services
This commit is contained in:
parent
6933014d75
commit
8c55205c66
1 changed files with 54 additions and 0 deletions
54
lib/modules/rclone.nix
Normal file
54
lib/modules/rclone.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{ 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
|
||||
scriptName = "rclone-pre";
|
||||
script = pkgs.writeShellScriptBin scriptName ''
|
||||
sleep 10
|
||||
'';
|
||||
in
|
||||
"${script}/bin/${scriptName}";
|
||||
|
||||
ExecStart =
|
||||
let
|
||||
scriptName = "rclone";
|
||||
script = pkgs.writeShellScriptBin scriptName ''
|
||||
systemctl --user start rclone.target
|
||||
'';
|
||||
in
|
||||
"${script}/bin/${scriptName}";
|
||||
};
|
||||
};
|
||||
|
||||
targets.rclone = {
|
||||
Unit = {
|
||||
Description = "rclone Mounts";
|
||||
Documentation = "man:rclone(1)";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue