Using Dropbox on Nixos

Thanks for sharing, i’ve added your code to the nixos wiki: Dropbox - NixOS Wiki

1 Like

Thanks a lot, Peter! I couldn’t hav come up with this for a pretty long time…

And here comes the real newbie follow-up question. I almost hesitate to ask, but let it be:
Dropbox provides .deb and .rpm packages for Linux on their donwload page. Since Nixos works differently - how would I go on with the installation?
Maybe there is some help in the manuals or wiki I’ve not found yet?

@mrtn22 Install the dropbox package after you have enabled unfree packages FAQ - NixOS Wiki. And then start the dropbox command.

1 Like

It’s also possible to install dropbox using flatpak. Not very nixy I guess, but works.

And that’s really the thing - you shouldn’t have to. We need to collectively get a lot better at making things work out of the box. I shouldn’t have sat on this without either updating the nixos module or at the very least document it.

2 Likes

Wow! nix-env -qaP really opened a completely new world to me.
Thanks a lot!

After reading this I tried to set up dropbox as a systemd user service however this seems to hang on the part where it opens firefox (not visible) to register the deamon with dropbox.

So I opened a nix-shell with the deamon and ran it to do the initial configuration in hopes of the systemd service then just using those generated config files. But it seems this is not the case. At least the PID of the deamon is not set in the respective file and the cli tool says that dropbox isn’t running.

So how do you configure the deamon for use with a systemd user service?

It launches firefox for me to do the login with the config above.

Apart from the KDE specific stuff I use a nearly identical config (without the KDE stuff given that I dont use a desktop environment but standalone Xmonad) but it doesn’t open firefox for me (at least not visible anywhere).

   dropbox = {
      description = "Dropbox";
      enable = true;
      serviceConfig = {
        ExecStart = "${pkgs.dropbox.out}/bin/dropbox";
        ExecReload = "${pkgs.coreutils.out}/bin/kill -HUP $MAINPID";
        KillMode = "control-group"; # upstream recommends process
        Restart = "on-failure";
        PrivateTmp = true;
        ProtectSystem = "full";
        Nice = 10;
      };
    };

I also tried to include the passing of the DISPLAY variable proposed by zimbatm above but that didn’t change things.

Given that the dropbox config exists in my home directory my understanding is that the firefox step should be skipped anyway, right?

The dropbox-cli package is actually nautilus-dropbox, see dropbox-cli: Fix and add Nautilus extension by jtojnar · Pull Request #60752 · NixOS/nixpkgs · GitHub

There is also https://github.com/NixOS/nixpkgs/blob/964934097737c1757e26889712333571f23a6343/pkgs/applications/networking/maestral/default.nix which is very nice and lightweight.

We currently have 0.4.2 in unstable with a PR open for 0.4.4 that needs a little work before it can be merged, so I would suggest either waiting for 0.4.4 or at least manually use 0.4.3 as 0.4.2 has some issues.

Would it feasible to have a nixos module for dropbox?

What do these mean in the dropbox service?

I don’t know if there is a written down policy about which user services should be a part of NixOS and which shouldn’t but FWIW, nixos/onedrive: init by SRGOM · Pull Request #77734 · NixOS/nixpkgs · GitHub on github was rejected

I do agree though, services would make using these packages much more user friendly.

Those are just dependencies.

We absolutely should have a module in NixOS - no reason not to.

1 Like

That is just standard systemd unit stuff. See here for descriptions of what each of those does.

There is a pull request for that now: nixos/dropbox: new module by romildo · Pull Request #85699 · NixOS/nixpkgs · GitHub

1 Like

Why aren’t you using NextSloud?
Everything is much simpler and more GB free (8 GB).
And it already exists in NixOS packages.

Can you clarify, in which file would this go? Also, given that now, June '23, there seems to be a dropbox package, is this still the way you’d do it?
Thanks

That earlier example would go into configuration.nix - please note that I no longer use dropbox (replaced it with maestral which is open source and doesn’t count against the 3 device maximum imposed by dropbox), so I don’t know if it still works.