Vagrant.configure("2") do |config|
  config.vm.box   = "generic/netbsd9"
  config.vm.guest = :netbsd

  # Make /sync once as vagrant:vagrant so rsync doesn't need sudo
  config.vm.provision "shell", inline: <<~'SH'
    set -e
    install -d -o vagrant -g vagrant /sync

    # Packages (runs as root)
    pkgin -y install git python312 rust mozilla-rootcerts
    # Update CA certificates
    mozilla-rootcerts install
    git --version
    python3 --version
    rustc --version
    cargo --version
  SH

  # sync fish-shell to /vagrant/fish-shell
  config.vm.synced_folder "../../..", "/home/vagrant/fish-shell",
    type: "rsync",
    rsync__rsync_path: "sudo rsync", # sudo in guest
    rsync__exclude: [".git/", ".git", "fish-shell/target/", "fish-shell/build/"],
    rsync__args: [
      "--archive", "--delete",
      "--no-owner", "--no-group",
      "--omit-dir-times",
      "--info=progress2", "--stats"
    ]


  config.vm.provider :libvirt do |v|
    v.cpus = 4
    v.memory = 2048
    # Max I/O for disposable builds. Remove if you need durability.
    v.disk_driver :cache => 'unsafe'
    # Note: NetBSD needs graphics on; leave default graphics enabled.
  end
end
