-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
programs.rclone: use 'config update' to preserve tokens #8335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Previously, the rclone module generated a static configuration file and used `install` to overwrite `rclone.conf` on every activation. This behavior caused data loss for remotes that rely on dynamic state, specifically the `token` field used by OAuth providers (e.g., Google Drive, OneDrive) to store rotating refresh tokens. This forced users to re-authenticate after every configuration switch. This change updates the activation logic to use `rclone config update`. This command safely merges the declarative configuration defined in Nix with the existing file, ensuring that dynamic keys like `token` are preserved while still enforcing the managed settings. This also simplifies the implementation by removing the need for `pkgs.formats.ini` and unifying the static configuration and secret injection into a single loop. Closes nix-community#8334
|
How come you don't use another config, as you can separate configs from secrets fairly easily And then the secrets in another |
|
Hi, this doesn't seem to build for me. Have you tried building it? |
How would this work? I don't think rclone supports multiple configs (yet). I might be wrong? |
Hi thanks for testing it! I must apologise because I've got a lot of mental state open right now. Are you saying that the hm module doesn't build, or that the minimal example I provided doesn't build? It did work when used as a flake input, and I could set the new options. But it's possible that I made a mistake. I'm going to have a proper look at this again at the weekend. If you're able to share how you are testing it specifically (i.e., what command you ran), then that would be very helpful. |
Actually I thought you could do this, my bad. In nix, it is not hard to merge attribute sets, so using the native home-manager rclone-config is probably the way to go and then point the the secrets path to the secrets file. Not as elegant or clean :/ |
It doesn't seem to build due to some shellcheck failures. Heres the command to run the integration tests |
Description
This fixes an issue where the
programs.rcloneactivation script unconditionally overwroterclone.confusinginstall. This behavior caused minor data loss for remotes that rely on dynamic state, specifically OAuth tokens (e.g., Google Drive, OneDrive), forcing users to re-authenticate after every configuration change or system reboot.Changes:
installcommand withrclone config update.token) are preserved.pkgs.formats.ini.Note on Drift:
This change introduces a minor trade-off: removing a setting from
home.nixwill no longer automatically remove it fromrclone.conf(it must be manually deleted). This is necessary to preserve the authentication tokens that Nix cannot manage.Closes #8334
Checklist
Change is backwards compatible.
Code formatted with
nix fmtornix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.Code tested through
nix run .#tests -- test-allornix-shell --pure tests -A run.all.(Note: Existing build tests pass. The fix addresses a runtime behavior (file overwrite) that cannot be reproduced in the sandboxed test suite, but was verified manually via VM reproduction.)
Test cases updated/added. See [example](f3fbb50#diff-b61a6d542f9036550ba9c401c80f00ef). -- Probably not desirable, it's not easy to construct a test for this as it requires a VM.
Commit messages are formatted like
See [CONTRIBUTING](https://nix-community.github.io/home-manager/#sec-commit-style) for more information and [recent commit messages](https://github.com/nix-community/home-manager/commits/master) for examples.
If this PR adds a new module (N/A)
If this PR adds an exciting new feature or contains a breaking change. (N/A)