GPG not using pinentry-curses

I am using home manager and trying to set up GPG with pinentry. I have been able to unlock it, but it opens in a gui dialog, and not curses. How can I fix this? This is part of my home manager config. I am running NixOS.

{ pkgs, ... }:
    programs.gpg.enable = true;

    services.gpg-agent = {
        enable = true;
        defaultCacheTtl = 1800;
        maxCacheTtl = 7200;
        pinentryFlavor = "curses";

This outputs the file .gnupg/gpg-agent.conf:

default-cache-ttl 1800
max-cache-ttl 7200
pinentry-program /nix/store/fjhf50n3fv2bz39p3910imxnv97cnw8p-pinentry-1.2.1-curses/bin/pinentry