Open brianmay opened 1 year ago
This is admittedly off-topic, but unless you absolutely need the actual dropbox client, I cannot strongly enough recommend maestral. Been using that for years as there is a limit to the number of clients you can use with the free plan, but maestral doesn't count against that.
@peterhoeg Do you by any chance have a sample home-manager config for maestral that will automatically start it in a systemd user based service?
Removing this in favour of the version with syntax highlighting. Not sure why this went through as plain text...
Backticks for easier skimming:
{ config, lib, pkgs, ... }:
let
cfg = config.hoeg.programs.dropbox;
inherit (lib)
mkEnableOption mkIf mkMerge mkOption types;
commonServiceConfig = {
KillMode = "control-group"; # dropbox upstream recommends process
NotifyAccess = "main";
Restart = "on-failure";
PrivateTmp = true;
ProtectSystem = "strict";
Nice = 10;
Slice = "background.slice";
};
environment = {
HOME = "%h";
};
wantedBy = [ "graphical-session.target" ];
ini = pkgs.formats.ini { };
defaultKeyring = "keyring.backends.kwallet.DBusKeyring";
# defaultKeyring = "automatic";
# defaultKeyring = "keyring.backends.SecretService.Keyring";
maestralIni = ini.generate "maestral-override.ini" {
app = {
# if we pass a bool here, it will end up as false which makes maestral blow up
analytics = "False";
notification_level = 30; # SYNCISSUE
update_notification_interval = 0;
};
# kwallet has support for SecretService, but it doesn't seem to work
auth = {
keyring = defaultKeyring;
};
};
keyringIni = ini.generate "keyringrc.cfg" {
backend.default-keyring = defaultKeyring;
};
in
{
meta.maintainers = with lib.maintainers; [ peterhoeg ];
options.hoeg.programs.dropbox = {
enable = mkEnableOption "Dropbox/Maestral";
preferMaestral = mkOption {
description = "Prefer maestral";
type = types.bool;
default = true;
};
runGUI = mkEnableOption "Run GUI tool";
folderPath = mkOption {
description = "Path to local dropbox folder";
type = types.nullOr types.str;
default = null;
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.preferMaestral {
environment.systemPackages = [
(pkgs.maestral.overrideAttrs (old: {
# doCheck = false;
}))
];
systemd.user.services = {
maestral = rec {
description = "Maestral - OpenSource Dropbox client";
conflicts = [ "dropbox.service" ];
restartTriggers = [ maestralIni ];
wants = [ ]; # [ "kwalletd5.service" ];
# we need kwallet to be running before maestral can fetch the auth
# token, so we *need* this to be a graphical session
after = wantedBy ++ wants;
inherit environment wantedBy;
unitConfig = {
ConditionUser = "!@system";
ConditionPathExists = [
"%h/.config/maestral/maestral.ini"
# do not set this here as each machine has its own path and thus sets it itself
] ++ lib.optional (cfg.folderPath != null) cfg.folderPath;
};
serviceConfig = with pkgs; (
commonServiceConfig // {
Type = "notify";
ExecStartPre = "/bin/sh -c '${pkgs.crudini}/bin/crudini --merge $HOME/.config/maestral/maestral.ini < ${maestralIni}'";
ExecStart = "${lib.getBin maestral}/bin/maestral start --foreground";
ExecStop = "${lib.getBin maestral}/bin/maestral stop";
# ExecStopPost = ''/bin/sh -c "test "$SERVICE_RESULT" != "success" && ${pkgs.libnotify}/bin/notify-send Maestral 'Daemon failed'"'';
ExecReload = "${lib.getBin coreutils}/bin/kill -HUP $MAINPID";
EnvironmentFile = "-%t/keys/maestral";
WatchdogSec = "60s";
RuntimeDirectory = "maestral";
}
);
};
};
})
(mkIf (! cfg.preferMaestral) {
networking.firewall = {
allowedTCPPorts = [ 17500 ];
allowedUDPPorts = [ 17500 ];
};
environment.systemPackages = [ pkgs.dropbox-cli ];
systemd.user.services.dropbox = rec {
description = "Dropbox";
after = wants ++ wantedBy;
wants = [ "xembed-sni-proxy.service" ];
conflicts = [ "maestral.service" "maestral-gui.service" ];
inherit environment wantedBy;
unitConfig = {
ConditionPathExists = mkIf (cfg.folderPath != null) cfg.folderPath;
ConditionUser = "!@system";
};
serviceConfig = with pkgs; (
commonServiceConfig // {
ExecStart = "${lib.getBin dropbox}/bin/dropbox";
ExecReload = "${lib.getBin coreutils}/bin/kill -HUP $MAINPID";
}
);
};
})
]);
}
Hi @eyJhb, I see you are listed as the Dropbox nix package maintainer.
Can confirm that dropbox is broken on latest stable and unstable NixOS.
Would you be willing to take a look? I'm using home-manager which doesn't say anything, but a manual dropbox start -i
results in No module named 'gi'
, which blocks Dropbox from running and syncing.
Same issue here.
Sorry, I no longer use Dropbox. I should most likely remove myself as maintainer :/
It would be great if a maestral user who's configured a working systemd user service to run the daemon could add a code snippet to https://nixos.wiki/wiki/Dropbox :pray:.
I'm also on 23.05 and dropbox (the actual client) is working fine for me. The only change is that dropbox-cli reports 'Dropbox isn't running!' if I call dropbox status
, even though I can update files and manually verify the changes have synced. This is my configuration.nix
:
systemd.user.services.dropbox = {
description = "Dropbox";
wantedBy = [ "default.target" ];
environment = {
QT_PLUGIN_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtPluginPrefix;
QML2_IMPORT_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtQmlPrefix;
};
serviceConfig = {
ExecStart = "${lib.getBin pkgs.dropbox}/bin/dropbox";
ExecReload = "${lib.getBin pkgs.coreutils}/bin/kill -HUP $MAINPID";
KillMode = "control-group";
Restart = "on-failure";
PrivateTmp = true;
ProtectSystem = "full";
Nice = 10;
};
};
❯❯❯ dropbox version
Dropbox daemon version: 178.3.4678
Dropbox command-line interface version: 2020.03.04
❯❯❯ systemctl --user status dropbox.service
● dropbox.service - Dropbox
Loaded: loaded (/etc/systemd/user/dropbox.service; enabled; preset: enabled)
Active: active (running) since Wed 2023-07-05 21:55:54 EDT; 4min 48s ago
Main PID: 2170 (bwrap)
Tasks: 86 (limit: 9367)
Memory: 398.3M
CPU: 10.286s
CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/dropbox.service
├─2170 /nix/store/hdmv0c9wdjp088y5yyy2mfgbysc7y8h3-bubblewrap-0.8.0/bin/bwrap --dev-bind /dev /dev --proc /proc --chdir /home/me --unshare-user --unshare-ipc --unshare-pid --unshare-uts --unshare-cg>
├─2192 /nix/store/hdmv0c9wdjp088y5yyy2mfgbysc7y8h3-bubblewrap-0.8.0/bin/bwrap --dev-bind /dev /dev --proc /proc --chdir /home/me --unshare-user --unshare-ipc --unshare-pid --unshare-uts --unshare-cg>
└─2195 /home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/dropbox
Jul 05 21:55:54 my-device systemd[2161]: Started Dropbox.
Jul 05 21:55:55 my-device dropbox[2195]: dropbox: load fq extension '/home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/cryptography.hazmat.bindings._openssl.abi3.so'
Jul 05 21:55:55 my-device dropbox[2195]: dropbox: load fq extension '/home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/cryptography.hazmat.bindings._padding.abi3.so'
Jul 05 21:55:55 my-device dropbox[2195]: dropbox: load fq extension '/home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/apex._apex.abi3.so'
Jul 05 21:55:55 my-device dropbox[2195]: dropbox: load fq extension '/home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/psutil._psutil_linux.cpython-38-x86_64-linux-gnu.so'
Jul 05 21:55:55 my-device dropbox[2195]: dropbox: load fq extension '/home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/psutil._psutil_posix.cpython-38-x86_64-linux-gnu.so'
Jul 05 21:55:56 my-device dropbox[2195]: dropbox: load fq extension '/home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/tornado.speedups.cpython-38-x86_64-linux-gnu.so'
Jul 05 21:55:58 my-device dropbox[2195]: dropbox: load fq extension '/home/me/.dropbox-dist/dropbox-lnx.x86_64-178.3.4678/wrapt._wrappers.cpython-38-x86_64-linux-gnu.so'
@amacfie I found a few snippets like that on github, but they seem to store credentials in plaintext by default. I don't think the native dropbox daemon does that?
I translated the maestral snippet above to work with home manager:
systemd.user.services.maestral = {
Unit.Description = "Maestral daemon";
Install.WantedBy = [ "default.target" ];
Service = {
ExecStart = "${pkgs.maestral}/bin/maestral start -f";
ExecStop = "${pkgs.maestral}/bin/maestral stop";
Restart = "on-failure";
Nice = 10;
};
};
So far seems to work.
I think a built in module that lets you do services.maestral.enable = true;
would be better.
@AlexChalk not sure I understand your concern, this doesn't do anything with passwords. Unless you are saying Meastral is insecure in the way it stores the credentials?
@AlexChalk I note you are not using the home manager module, i.e. dropbox.service.enable = true;
- wonder if this is why it works for you...
On migrating from the official Dropbox client to Maestral I've also been having troubles with needing to reauthenticate often (about weekly?), and not being able to sync files with sizes over 350 GB. Assume these are limitations enforced by Dropbox but might be good to be aware of that the clients don't have feature parity.
Perhaps Maestral needs it's own Github issue ;-)
I'm not planning on migrating away from the official Dropbox client and currently the official client is broken on stable NixOS.
I'm also experiencing this issue right on 23.05 (with home-manager).
ModuleNotFoundError: No module named 'gi'
This line https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/dropbox/cli.nix#L47 is missing at runtime
Describe the bug
Dropbox fails to install in new 23.05 install.
Steps To Reproduce
Expected behavior
It should start without errors.
Screenshots
As above.
Additional context
This is a new install of nixos 23.05, and dropbox installed using home-manager.
Notify maintainers
@ttuegel
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.