1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-02-17 05:35:06 +01:00

dropbox: use dropbox package

The dropbox-cli package is not well maintained and no longer works as
used here. The dropbox package has more support and is currently
working. As such, these changes switch the system from dropbox-cli to
dropbox.
This commit is contained in:
Taylor Henderson 2024-10-01 13:48:26 -04:00 committed by Robert Helgesson
parent fe56302339
commit aec88e0e6f
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
2 changed files with 21 additions and 30 deletions

View file

@ -6,11 +6,11 @@ let
cfg = config.services.dropbox;
baseDir = ".dropbox-hm";
dropboxCmd = "${pkgs.dropbox-cli}/bin/dropbox";
dropboxCmd = "${pkgs.dropbox}/bin/dropbox";
homeBaseDir = "${config.home.homeDirectory}/${baseDir}";
in {
meta.maintainers = [ maintainers.eyjhb ];
meta.maintainers = [ maintainers.tph5595 ];
options = {
services.dropbox = {
@ -33,7 +33,7 @@ in {
lib.platforms.linux)
];
home.packages = [ pkgs.dropbox-cli ];
home.packages = [ pkgs.dropbox ];
systemd.user.services.dropbox = {
Unit = { Description = "dropbox"; };
@ -41,40 +41,34 @@ in {
Install = { WantedBy = [ "default.target" ]; };
Service = {
Environment = [ "HOME=${homeBaseDir}" "DISPLAY=" ];
Environment = [ "HOME=${homeBaseDir}" ];
Type = "forking";
PIDFile = "${homeBaseDir}/.dropbox/dropbox.pid";
Restart = "on-failure";
PrivateTmp = true;
ProtectSystem = "full";
Nice = 10;
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
ExecStop = "${dropboxCmd} stop";
ExecStop = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
ExecStart = toString (pkgs.writeShellScript "dropbox-start" ''
# ensure we have the dirs we need
run ${pkgs.coreutils}/bin/mkdir $VERBOSE_ARG -p \
${pkgs.coreutils}/bin/mkdir $VERBOSE_ARG -p \
${homeBaseDir}/{.dropbox,.dropbox-dist,Dropbox}
${pkgs.coreutils}/bin/touch ${homeBaseDir}/.dropbox-dist/VERSION
# symlink them as needed
if [[ ! -d ${config.home.homeDirectory}/.dropbox ]]; then
run ${pkgs.coreutils}/bin/ln $VERBOSE_ARG -s \
${pkgs.coreutils}/bin/ln $VERBOSE_ARG -s \
${homeBaseDir}/.dropbox ${config.home.homeDirectory}/.dropbox
fi
if [[ ! -d ${escapeShellArg cfg.path} ]]; then
run ${pkgs.coreutils}/bin/ln $VERBOSE_ARG -s \
${pkgs.coreutils}/bin/ln $VERBOSE_ARG -s \
${homeBaseDir}/Dropbox ${escapeShellArg cfg.path}
fi
# get the dropbox bins if needed
if [[ ! -f $HOME/.dropbox-dist/VERSION ]]; then
${pkgs.coreutils}/bin/yes | ${dropboxCmd} update
fi
${dropboxCmd} start
${dropboxCmd}
'');
};
};

View file

@ -1,19 +1,16 @@
{ config, pkgs, ... }:
{
config = {
services.dropbox = {
enable = true;
path = "${config.home.homeDirectory}/dropbox";
};
test.stubs.dropbox-cli = { };
nmt.script = ''
serviceFile=home-files/.config/systemd/user/dropbox.service
assertFileExists $serviceFile
'';
services.dropbox = {
enable = true;
path = "${config.home.homeDirectory}/dropbox";
};
test.stubs.dropbox = { };
nmt.script = ''
serviceFile=home-files/.config/systemd/user/dropbox.service
assertFileExists $serviceFile
'';
}