//go:build linux

package spindle

import (
	"context"

	"tangled.org/core/log"
	"tangled.org/core/spindle/config"
	"tangled.org/core/spindle/db"
	"tangled.org/core/spindle/engines/dummy"
	"tangled.org/core/spindle/engines/microvm"
	"tangled.org/core/spindle/engines/nixery"
	"tangled.org/core/spindle/models"
)

func buildEngines(ctx context.Context, cfg *config.Config, d *db.DB) (map[string]models.Engine, error) {
	nixeryEng, err := nixery.New(ctx, cfg)
	if err != nil {
		return nil, err
	}

	microvmEng, err := microvm.New(ctx, cfg, d)
	if err != nil {
		return nil, err
	}

	return map[string]models.Engine{
		"nixery":  nixeryEng,
		"microvm": microvmEng,
		"dummy":   dummy.New(log.FromContext(ctx)),
	}, nil
}
