Autostart of KeePassXC conflicts with gpg smartcard

I have a Nitrokey USB smartcard. I use gpg --card-status to check if it is working (if gpg is configured correctly). With my current NixOS configuration, this works.

But if I add the following snippet to start KeePassXC on login with GNOME, this changes.

{ config, pkgs, lib, ... }:
  home-manager.users.yoda = { osConfig, config, pkgs, ... }: {
    home.file.keepassxc = {
      target = ".config/autostart/" + "org.keepassxc.KeePassXC" + ".desktop";
      source = (pkgs.keepassxc + "/share/applications/" + "org.keepassxc.KeePassXC" + ".desktop");

After a reboot, KeePassXC is started on login. But gpg --card-status gives the following message, which is the same as if no smartcard is attached:

gpg: selecting card failed: No such device
gpg: OpenPGP card not available: No such device

I have no idea how I could debug this further … Any help is welcome.

In case this hepls, my NixOS configuration is public.

I have multiple modules (nix-git/modules at main - nix-git - that get imported in my main configuration file (nix-git/configuration.nix at main - nix-git -

The autostart snipped is from this module (nix-git/autostart.nix at main - nix-git - and my gpg/smartcard is configured in a separate module (nix-git/nitrokey-ssh-gpg.nix at main - nix-git -

It was a timing issue between pcscd and scdaemon using the internal ccid driver. More details are provided here: Troubleshooting - Nitrokey Documentation

I was able to resolve this issue by adding this to my Home Manager configuration:

    programs.gpg = {
      enable = true;
      scdaemonSettings = {
        disable-ccid = true;