Referencing NixOS options

I’m trying to create a nixops file to configure a webserver with php-fpm and the caddy webserver. I need to reference the location of the php-fpm socket in the caddy configuration. According to the NixOS options docs, this is available in the phpfpm.pools.<name>.socket option, but when trying to use it I’m getting error: attribute 'socket' missing. Here’s my code:

let
  users = {
    users.sephi = {
      isNormalUser = true;
      extraGroups = [ "wheel" ];
    };
  };
in
{
  network.enableRollback = true;

  myserver = { config, pkgs, ... }: {
    deployment.targetHost = "...";
    networking.firewall.allowedTCPPorts = [ 80 443 22 ];

    containers.bookstack =
      { config = rec {
          services.phpfpm.pools.default = {
            user = "php";
            group = "php";
            phpPackage = pkgs.php;
          };

          services.caddy = {
            enable = true;
            agree = true;
            config = ''
              auto_https off

              root * /var/www
              php_fastcgi ${services.phpfpm.pools.default.socket};
              file_server
            '';
          };
        };
        autoStart = true;
    };

    inherit users;
  };
}

I guess the problem comes from the fact that the phpfpm.pools.<name>.socket option is not defined at the time of evaluation in the services.caddy.config string? How can I access this value?

I haven’t done this myself but my first inclination is to say that this string should be reading the value out of config, because AIUI that’s the fully-evaluated configuration, right?

Oh, I was sure I tried it and it didn’t work! I guess I had a typo somewhere… anyway, got it working with php_fastcgi ${config.containers.bookstack.config.services.phpfpm.pools.default.socket};.

Thanks!