Programs modifying config files created by home-manager

(Disclaimer: first ever post on a linux forum, 1yr linux user, 1 week NixOS)

Hi Everyone,

Is anyone able to point me to resources needed to understand the issue and adopt best practice for the following. I have:

  • NixOS 23.11
  • Home Manager Standalone installation
  • rclone 1.64.2 installed system wide

i specify/hardcode .config/rclone/rclone.conf in home.nix …

for onedrive and google drive, rclone.conf is periodically updated by rclone. if rclone.conf is not updated, one loses write access to these cloud services until it is.

since home manger has created the rclone.conf file though, rclone does not have write access to it.
(i tried sudo rclone as quick fix, but then it wanted .config in root folder not in home)

indeed, even if rclone did have write access to rclone.conf, it wouldn’t change what i have hardcoded into home.nix - consequently the next time I “home-manager switch” i would lose the changes to rclone.conf anyhow, as they are specified in home.nix.

i’m curious to know what best practice is in this scenario. in addition to allowing rclone permissions to update the current instance rclone.conf, perhaps de-hardcoding home.nix so it refers to a separate file and then somehow periodically updating that file to what is in rclone.conf… neither of which know how to do.

or perhaps home-manager isn’t suitable for this use case. i just want programs to work ‘out of the gate’ each time i switch.

Thanks, Chris.

Yeah, this comes down to rclone not being particularly well thought-out: Separate mutable state from configuration (read only config file) · Issue #3655 · rclone/rclone · GitHub

They’re storing state in a configuration file, this means your configuration file is data, and as a result rclone cannot be configured declaratively.

You’ll have to wait for that bug to be fixed for google drive & co, since there the token refreshes and stuff are necessary for authentication. For some other values that rclone implicitly adds (e.g. shell type when using sftp) you can hardcode them.