Duplicity service gpg error

I can’t get this service to work. It fails with the error

May 22 09:01:02 nixos-thinkpad duplicity[2200]: Copying duplicity-full-signatures.20210506T165545Z.sigtar.gpg to local cache.
May 22 09:01:03 nixos-thinkpad duplicity[2200]: GPGError: GPG Failed, see log below:
May 22 09:01:03 nixos-thinkpad duplicity[2200]: ===== Begin GnuPG log =====
May 22 09:01:03 nixos-thinkpad duplicity[2200]: gpg: AES.CFB encrypted data
May 22 09:01:03 nixos-thinkpad duplicity[2200]: gpg: encrypted with 1 passphrase
May 22 09:01:03 nixos-thinkpad duplicity[2200]: gpg: decryption failed: Bad session key
May 22 09:01:03 nixos-thinkpad duplicity[2200]: ===== End GnuPG log =====
May 22 09:01:03 nixos-thinkpad systemd[1]: duplicity.service: Main process exited, code=exited, status=31/n/a
May 22 09:01:03 nixos-thinkpad systemd[1]: duplicity.service: Failed with result 'exit-code'.

I have this in my config

    duplicity = {
      enable = true;
      root = "/home/florian";
      include = [  "/home/florian/Dokumente" "/home/florian/.password-store" ];
      exclude = [ "**" ];
      targetUrl = "scp://flo@ip/home/flo/backups";
      frequency = "weekly";
      secretFile = "/root/duplicitySecret";
   }

I also tried adding some extra flags

  extraFlags = [ "--gpg-options"  "\"--pinentry-mode=loopback\""];

/root/duplicitySecret

PASSPHRASE=PW
HOME=/root
GPG_KEY='Key'
GPG_PW='PW'
GPG_OPTS='--pinentry-mode loopback'

If i run the comand from the service manual as root i get the same error. As my regular user it is working. Encryption and decryption with gpg as root is also working.

I can’t get this service to work. It fails with the error

As configured it runs as root. You need to configure it to run as a user service instead if it needs access to your keyring.

Than i can’t use the module, right? Anyway, I’m using borgbackup now.

Than i can’t use the module, right? Anyway, I’m using borgbackup now.

This module is really meant for “appliance mode” and not for individual, interactive users. The proper way to do that
would be in home-manager.