with apologies

OneDrive and NixOS

Richard Mortier · 2 min read · August 22, 2023 · #old #tech #linux #nixos

Starting by reading instructions at:

FWIW I also use that package on a NixOS system (via a Nix package that can presumably be installed on other systems if you add nix as a package manager), https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/onedrive.nix.

I have successfully used it with the University and my startup’s tenancies (both personal OneDrive and enterprise Sharepoint sites) simultaneously – this was fairly simple in the end but I recall it took a while to do the token dance to get the necessary tokens, and then to get all the runes right. In short it was something like:

  1. Follow the instructions Robert pointed to sort out access to the various accounts, refresh tokens, and the like.

  2. Create file ~/.config/onedrive-launcher comprising each subdirectory of ~/.config that is a onedrive configuration directory corresponding to each account – I named these after the accounts in question so mine contained

onedrive-rmm1002@cam.ac.uk
onedrive-mort@ikva.ai
sharepoint-mort@ikva.ai-iKVALimited

(I now prefix the last two lines with # to comment them out as I don’t need those synced any more.)

The systemd service onedrive-launcher.service then uses the file to kick off a systemd onedrive@... service for each entry.

  1. Edit the ~/.config/ACCOUNT/config files appropriately; the only changes I made were to
# for my University account
sync_dir = "~/OneDrive/rmm1002@cam.ac.uk"

# for my startup personal OneDrive
sync_dir = "~/OneDrive/mort@ikva.ai"
sync_business_shared_folders = "true"

# for startup Sharepoint sites
sync_dir = "~/OneDrive/mort@ikva.ai-iKVA_Limited"
drive_id = "..." # rune found per instructions Robert pointed to I think