1Password can't save MFA code

I have my 1password set up to require an MFA code, which works well outside NixOS. However, on NixOS after I enter the code it accepts it but says “1Password was unable to save your two-factor token”. On Arch I was able to eventually fix this, but I don’t quite remember how. I think I had to set up a keyring somehow, but I don’t remember. Does anyone else use this 1Password set up and know how to get it working on NixOS?

I’m using the Cosmic desktop environment, if that matters.

My config for 1Password is here: nixos-configs/modules/1password/default.nix at 662daa3fce89cc915516d61156efb48dcb707570 · mythmon/nixos-configs · GitHub, and you can see the rest of the config in that repo too.

Yes, you’ll need some sort of keyring. I personally use keepassxc with this setting turned on:

image

But yknow, pick whatever floats your boat. I don’t know if cosmic has one already.

Cosmic doesn’t have one of its own, but I think that the Nix configs for it enable gnome-keyring: nixos-cosmic/nixos/cosmic/module.nix at 6946e5432b3217ac3de84da065f766e55f9b4cd2 · lilyinstarlight/nixos-cosmic · GitHub

Is there anyway I can confirm that the keyring is available, or debug what 1Password is doing with it?

I tried to set up KeepassXC, and it said that Gnome Keyring is already running, so that confirms that Gnome Keyring is running. That’s extra puzzling.

After some more digging and research, I figured out that the problem was that when I used my fingerprint auth to sign in, it didn’t automatically unlock the keyring. Due to some things I didn’t quite understand, 1password couldn’t automatically unlock it either.

I learned that running this command after I log in allows the keyring to work as expected, including automatic unlocks where appropriate.

dbus-update-activation-environment --all