I am trying to create a systemd service using home-manager using rclone to mount a remote service, but it refuses to allow me to mount. I can mount manually, so it is not clear to me where it goes wrong.
I tried the solutions here, here, and here but without success.
Here is my home-manager config i use:
{ config, pkgs, lib, ... }:
let
createRcloneMountService = { name, remote, mountPath ? "/home/${config.home.username}/${name}", remotePath ? "/" }: {
Unit = {
Description = "Rclone mount service for ${name}";
After = [ "network-online.target" ];
};
Service = {
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${mountPath}";
ExecStart = ''
${pkgs.rclone}/bin/rclone mount
--config /home/${config.home.username}/.config/rclone/rclone.conf
--vfs-fast-fingerprint
--vfs-cache-mode full
${remote}:${remotePath} ${mountPath}
'';
ExecStop = "${pkgs.fuse3}/bin/fusermount -u ${mountPath}";
Type = "notify";
Restart = "on-failure";
RestartSec = "10s";
Environment = [ "PATH=/run/wrappers/bin/:$PATH" ];
};
Install = {
WantedBy = [ "default.target" ];
};
};
in
{
home.packages = with pkgs; [
rclone
fuse3
];
systemd.user.startServices = true;
systemd.user.services = {
# Create the rclone mount services by calling the function with the desired parameters using named arguments
rclone-mount-dropbox-private = createRcloneMountService {
name = "dropbox-private";
remote = "dropbox-private";
};
};
}
I konw it works on my NixOS config on another machine using the nixos/configuration.nix but when I migrate it to home-manager i get the error:
❯ systemctl status --user rclone-mount-dropbox-private.service
● rclone-mount-dropbox-private.service - Rclone mount service for dropbox-private
Loaded: loaded (/home/myuser/.config/systemd/user/rclone-mount-dropbox-private.service;>
Active: activating (auto-restart) (Result: exit-code) since Thu 2024-06-13 18:34:54 >
Process: 84456 ExecStartPre=/nix/store/php4qidg2bxzmm79vpri025bqi0fa889-coreutils-9.5>
Process: 84458 ExecStart=/nix/store/pi5lhi3pdy9f9a8k7g5rcnhyvcsc8b9b-rclone-1.66.0/bi>
Main PID: 84458 (code=exited, status=1/FAILURE)
Status: "[18:34] vfs cache: objects 0 (was 0) in use 0, to upload 0, uploading 0, to>
CPU: 161ms
❯ journalctl --user -xeu rclone-mount-dropbox-private.service
Jun 13 18:35:26 ubuntu-laptop rclone[84676]: mount helper error: fusermount3: mount >
Jun 13 18:35:26 ubuntu-laptop rclone[84676]: Fatal error: failed to mount FUSE fs: f>
Jun 13 18:35:26 ubuntu-laptop systemd[2262]: rclone-mount-dropbox-private.service: M>