How to default an option based on its index in a listOf?

I am not sure how to express my question with the proper nix terminology so here is a NixOS module:

{ config, lib, ... }:
with lib;
let
  siteOptions = with types; { name, ... }: {
    options = {
      name = mkOption {
        type = str;
        default = "site-${name}";
        description = ''
          Name of the site.
        '';
      };

      ipv4 = mkOption {
        type = str;
        example = "10.0.0.1/24";
        description = ''
          IPv4 of the site.
        '';
      };
    };
  };
in
{
  options = {

    mysites = with types; {

      enable = mkOption {
        type = bool;
        default = false;
        description = ''
          Whether to enable mysites.
        '';
      };

      sites = mkOption {
        type = listOf (submodule siteOptions);
        default = [];
      };
    };
  };
}

I would like to have mysites.sites.*.name defaults to site-<index-in-the-list> (e.g. site-1, site-2, …).

So for this configuration:

mysites = {
  enable = true;
  sites = [
    { ipv4 = "10.0.0.1/24"; }
    { ipv4 = "10.0.0.2/24"; }
  ];
};

I would like this result for mysites:

{
  "enable": true,
  "sites": [
    {
      "ipv4": "10.0.0.1/24",
      "name": "site-1"
    },
    {
      "ipv4": "10.0.0.2/24",
      "name": "site-2"
    }
  ]
}

and not what is currently returned:

{
  "enable": true,
  "sites": [
    {
      "ipv4": "10.0.0.1/24",
      "name": "site-[definition 1-entry 1]"
    },
    {
      "ipv4": "10.0.0.2/24",
      "name": "site-[definition 1-entry 2]"
    }
  ]
}

What is the proper nix way of doing that?

I don’t believe there is any way. The name argument is equal to the last element of the option definition’s loc, and for listOf, the merge operator for the type builds the loc entry [definition N-entry M]. I don’t see any other

something with range to generate a list and then zipListsWith, perhaps. little cursed