How to deploy n instances of machine using NixOps?

I would like to deploy say 100 VMs on Virtualbox using NixOps.

The load-balancer.nix example shows how to deploy 2 exact same machines, but how can i deploy n effectively?

I could write this, but that would not be very effectively:

  backend1 = backend;
  backend2 = backend;
  backendn = backend;

I haven’t ever done anything this before, but presumably you could write something like

{
  # all other attrs
  # …
} // lib.attrsets.genAttrs (map (i: "backend${toString i}") (lib.lists.range 1 100)) (_: backend)

Edit: Alternative syntax if you care for it:

{
  # all other attrs
  # …
} // builtins.foldl' (a: b: a // b) {} (map (i: { "backend${toString i}" = backend; }) (lib.lists.range 1 100))

Thanks.

I got this error that lib is not defined

error: undefined variable 'lib' at /home/davidak/code/nixops-targets/load-balancer.nix:36:6
error: evaluation of the deployment specification failed

but found the solution in the manual:

https://nixos.org/nixops/manual/#examples-18

with import <nixpkgs/lib>;

(The example in the manual is outdated btw)