home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

module request: rclone

Open chayleaf opened this issue 3 years ago • 8 comments

Description

rclone is a tool that lets you manage cloud files using one of the many backends (Google Drive, Dropbox, FTP, etc). In particular, two would-be-nice-to-have home-manager integrations are declarative remote management and FUSE mounts using systemd.

chayleaf avatar Feb 06 '22 18:02 chayleaf

I'm willing to take this on.

However, some details definitely need to be thought about, most importantly: how do we handle secrets in the configuration file? rclone's configuration contains storage provider credentials, so we'd need a good way to store and provide this to the configuration without making it readable in the store.

I think something that can be considered is allowing the user to use rclone config to generate a configuration file, and then use their method of choice (agenix, sops-nix, etc.) to provide a path to it to the module. This would allow interactive authentication and such, which wouldn't be so easy if the only interface was a Nix expression.

Thoughts and opinions on this are welcome (and encouraged!).

winterqt avatar Feb 16 '22 03:02 winterqt

rclone supports config file encryption. I'm not sure how else this could be done, besides perhaps not including remote passwords in the config file at all (only letting the user specify a password file for rclone mounts). Alternatively, we could ask upstream to add an option to use a command as the remote password.

chayleaf avatar Feb 16 '22 13:02 chayleaf

rclone supports config file encryption.

How would this interact with automatic mounting units, though?

A command or a file parameter for the password upstream is a good solution, but I'm not sure if there's a better way.

winterqt avatar Feb 16 '22 15:02 winterqt

How would this interact with automatic mounting units, though?

you can pipe the password via stdin for sure, you might be able to pass it via cmd line too.

edit: see this, it lets one specify the password command for config encryption. Though, if at all possible, not including the password in the config file should be better

chayleaf avatar Feb 16 '22 19:02 chayleaf

Did anyone started with this? Maybe we could just start first with the config and see later how we could handle units? 😅

shyim avatar Apr 30 '22 09:04 shyim


{ config, pkgs, lib, ... }:

with lib;

let

  cfg = config.programs.rclone;
  configOptions = types.nullOr (types.oneOf [
        types.bool
        types.int
        types.float
        types.str
        (types.lazyAttrsOf configOptions)
        (types.listOf configOptions)
      ]) // {
        emptyValue.value = { };
      };

in {
    options.programs.rclone = {
        enable = mkEnableOption "rclone";

        package = mkOption {
            type = types.package;
            default = pkgs.rclone;
            defaultText = literalExpression "pkgs.rclone";
            description = "The package to use for rclone.";
        };

        settings = mkOption {
            type = configOptions;
            default = {};
        };
    };

    config = mkIf cfg.enable {
        home.packages = [ cfg.package ];

        xdg.configFile."rclone/rclone.conf" = mkIf (cfg.settings != { }) {
            text = lib.generators.toINI {} cfg.settings;
        };
    };
}
programs.rclone.enable = true;
programs.rclone.settings.Foo = {
    type = "drive";
};

I would just throw then my secrets here too and then encrypt that file for my dotfiles git repository 🤔 .

shyim avatar Apr 30 '22 10:04 shyim

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Jul 30 '22 00:07 stale[bot]

Also rclone is mostly configured through the interactive cli especially when you need to do some oauth2.

👎🏼 from me

SuperSandro2000 avatar Jul 30 '22 16:07 SuperSandro2000

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Oct 28 '22 23:10 stale[bot]

what about simply letting the user specify the paths to secrets? I suppose that would be handled in an activation script?

chayleaf avatar Aug 28 '23 20:08 chayleaf

Also rclone is mostly configured through the interactive cli especially when you need to do some oauth2.

rclone has many different use cases; the interactive cli isn't necessary, and in fact neither is a config file (it can be configured "on the fly" using CLI arguments, fstab options, etc.).

Config files also won't necessarily contain secrets, e.g. SFTP uses ~/.ssh, S3 uses ~/.aws, etc. which have separate management solutions. If that's a blocker, it may be easier to avoid secrets to begin with.

Warbo avatar Sep 12 '23 14:09 Warbo

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Dec 12 '23 04:12 stale[bot]