Rclone: Difference between revisions

Sedlund (talk | contribs)
m spelling
DHCP (talk | contribs)
m fix indentation
 
(4 intermediate revisions by 4 users not shown)
Line 27: Line 27:
== Configuration with Home-Manager ==
== Configuration with Home-Manager ==
Home-manager users may wish to make a user-centric configuration of rclone. To do so add <code>pkgs.rclone</code> to your <code>~/.config/home-manager/home.nix</code> file. You can also configure remotes with home-manager. Here is an example below.<syntaxhighlight lang="nix">
Home-manager users may wish to make a user-centric configuration of rclone. To do so add <code>pkgs.rclone</code> to your <code>~/.config/home-manager/home.nix</code> file. You can also configure remotes with home-manager. Here is an example below.<syntaxhighlight lang="nix">
  home.packages = [ pkgs.rclone ];
home.packages = [ pkgs.rclone ];
  home.file = {
xdg.configFile."rclone/rclone.conf".text = ''
      ".config/rclone/rclone.conf".text = ''
  [fichier]
[fichier]
  type = fichier
type = fichier
  user = foo@bar.com
user = foo@bar.com
  pass = password
pass = password
'';
    '';
  };
</syntaxhighlight>
</syntaxhighlight>


Particular concern should be made when uploading such configurations online as your passwords will be plainly visible. It is recommended to instead put  the passwords in a local file if such is needed. Keep in mind that if you do output to .config/rclone/rclone.conf, every time you switch your home-manager configuration it will be overwritten. It would be wiser to instead output to a separate file, especially if using SystemD services as in the example below.   
Particular concern should be made when uploading such configurations online as your passwords will be plainly visible. It is recommended to instead put  the passwords in a local file if such is needed. Keep in mind that if you do output to .config/rclone/rclone.conf, every time you switch your home-manager configuration it will be overwritten. It would be wiser to instead output to a separate file, especially if using systemd services as in the example below.   


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
  home.file = {
xdg.configFile."rclone/example.conf".text = ''
      ".config/rclone/example.conf".text = ''
  [fichier]
[fichier]
  type = fichier
type = fichier
  user = foo@bar.com
user = foo@bar.com
  pass = p4ssw0rd
pass = p4ssw0rd
'';
    '';
};
 
systemd.user.services.example-mounts = {
  Unit = {
    Description = "Example programmatic mount configuration with nix and home-manager.";
    After = [ "network-online.target" ];
   };
   };
 
   Service = {
   systemd.user.services.example-mounts = {
     Type = "notify";
     Unit = {
    ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p %h/Example Sync Dir";
      Description = "Example programmatic mount configuration with nix and home-manager.";
    ExecStart = "${pkgs.rclone}/bin/rclone --config=%h/.config/rclone/example.conf --vfs-cache-mode writes --ignore-checksum mount \"fichier:\" \"%h/Example Sync Dir\"";
      After = [ "network-online.target" ];
    ExecStop="/run/wrappers/bin/fusermount -u %h/Example Sync Dir/%i";
    };
    Service = {
      Type = "notify";
      ExecStartPre = "/usr/bin/env mkdir -p %h/Example Sync Dir";
      ExecStart = "${pkgs.rclone}/bin/rclone --config=%h/.config/rclone/example.conf --vfs-cache-mode writes --ignore-checksum mount \"fichier:\" \"Example Sync Dir\"";
      ExecStop="/bin/fusermount -u %h/Example Sync Dir/%i";
    };
    Install.WantedBy = [ "default.target" ];
   };
   };
  Install.WantedBy = [ "default.target" ];
};
</syntaxhighlight>
</syntaxhighlight>


  [[Category:Applications]]
[[Category:Applications]]
[[Category:CLI Applications]]
[[Category:Backup]]
[[Category:Backup]]