Using Open vSwitch with LXD

I am attempting to use Open vSwitch with LXD containers. I’ve enabled both, along with supporting options, in configuration.nix:

  virtualisation.lxd.enable = true;
  virtualisation.lxd.zfsSupport = true;
  virtualisation.lxc.lxcfs.enable =  true;
  virtualisation.vswitch.enable = true;

Attempting to create a network which uses OVS

$ lxc network create ovsnet --type=bridge bridge.driver=openvswitch

gives the error message

Error: Open vSwitch isn't installed on this system

It doesn’t matter if the command is run with normal or elevated privileges. The same error occurs.

Note: ovs-vsctl is accessible in both the root and user environments

# ovs-vsctl --version
ovs-vsctl (Open vSwitch) 2.17.0
DB Schema 8.3.0
$ ovs-vsctl --version
ovs-vsctl (Open vSwitch) 2.17.0
DB Schema 8.3.0

Thanks to assistance from the LXD community it is apparent that ovs-vsctl is indeed not in the path of the LXD daeamon (pid 2325233) and hence cannot be used by the daemon.

 ps aux | awk '/bin\/lxd/{print $2}'
2325233
$ sudo cat /proc/2325233/environ | tr '\0' '\n' | grep PATH | sed 's/PATH=//;s/:/\n/g'
/nix/store/1j8bp97d7m9j7pzm58q2fhqfm1p3pnzi-iptables-1.8.7/bin
/nix/store/b9cgfd1ly01khk5kfrqq3gjrjfhxqxj5-acl-2.3.1-bin/bin
/nix/store/l2cvi0rfkrm14axd6fidixldayf2x1q7-rsync-3.2.3/bin
/nix/store/mnln1nxdhxx5qj8rcyvllhhs6d4h668b-gnutar-1.34/bin
/nix/store/plwz40xsmqsiq5gqavij50lp9vzpn2p6-xz-5.2.5-bin/bin
/nix/store/71kz0gns59s0ixwpjrp96wgxwdzhsf2d-btrfs-progs-5.17/bin
/nix/store/6707csjy3qf4p9anrrg3lbsjlh7il7lh-gzip-1.12/bin
/nix/store/ffsaal905zxdgdc39r5gqini7ls2wid3-dnsmasq-2.86/bin
/nix/store/n5fdwh6ay0h5217wbc7qxl6ps34hi0w3-squashfs-4.5.1/bin
/nix/store/fjbhss3462zaf8dwgbw7fz0w3kqynv3k-iproute2-5.17.0/bin
/nix/store/xbdqbi2mscmhl5wcpbgpjdwxbsrvpkil-bash-5.1-p16/bin
/nix/store/mkjh5k224ch5wb51rqmp3a8mgn1g2ykk-criu-3.15/bin
/nix/store/gdh49qwa3diyfdsxg9azh738pyarmdaw-attr-2.5.1-bin/bin
/nix/store/99vgmb9xbdlfrvdgv3b84i6w7j1qmyh8-apparmor_parser/bin
/nix/store/56cnxji4339lgb3my8fpg289cgs8q5f9-zfs-user-2.1.5/bin
/nix/store/p643r4aczmzb0dhyrx3dj592f0s5v7xj-coreutils-9.0/bin
/nix/store/7g48ahc3xnmb5b851vw60nbdgvk0wsf8-findutils-4.9.0/bin
/nix/store/ja8bi2cbpm36nwqy1hvklm3y9n7s3247-gnugrep-3.7/bin
/nix/store/lrxxki2m4gr4w3lxw08qpd465skpa04y-gnused-4.8/bin
/nix/store/vqy0ljiks17602r88abb4z3lwzny70qh-systemd-250.4/bin
/nix/store/56cnxji4339lgb3my8fpg289cgs8q5f9-zfs-user-2.1.5/sbin
/nix/store/p643r4aczmzb0dhyrx3dj592f0s5v7xj-coreutils-9.0/sbin
/nix/store/7g48ahc3xnmb5b851vw60nbdgvk0wsf8-findutils-4.9.0/sbin
/nix/store/ja8bi2cbpm36nwqy1hvklm3y9n7s3247-gnugrep-3.7/sbin
/nix/store/lrxxki2m4gr4w3lxw08qpd465skpa04y-gnused-4.8/sbin
/nix/store/vqy0ljiks17602r88abb4z3lwzny70qh-systemd-250.4/sbin

I believe what is wanted in the long term is an option, virtualisation.lxd.vSwitchSupport perhaps, which adds the path of ovs-vsctl into the LXD deamon’s PATH variable. In the short term though, it is sufficient to add it to package using an overlay. Unfortunately, my skill with NixOS is insufficient to accomplish this.

What is the appropriate Nix expression to place in configuration.nix to add the Open vSwitch package to the LXD deamon path?