[buildout]
extends =
  ../../component/caddy/buildout.cfg
  ../../component/git/buildout.cfg
  ../../component/bash/buildout.cfg
  ../../component/bash-completion/buildout.cfg
  ../../component/fish-shell/buildout.cfg
  ../../component/tmux/buildout.cfg
  ../../component/tig/buildout.cfg
  ../../component/vim/buildout.cfg
  ../../component/curl/buildout.cfg
  ../../component/coreutils/buildout.cfg
  ../../component/fonts/buildout.cfg
  ../../component/theia/buildout.cfg
  ../../stack/slapos.cfg
  ../../stack/monitor/buildout.cfg
  ../../stack/resilient/buildout.cfg
  ../../component/defaults.cfg
  ./buildout.hash.cfg

parts =
  theia-wrapper
  slapos-cookbook
  python-for-resiliency
  python-for-standalone
  instance-theia
  instance
  instance-import
  instance-export
  instance-resilient
  theia-common
  theia-export

# default for slapos-standalone
shared-part-list =


# Versions
# --------

[gcc]
# We keep the gcc part in sync with the one from erp5 software, so that when we install
# erp5 inside theia's slapos parts can be shared.
max_version = 0

[nodejs]
<= nodejs-16.13.2

[gowork]
install +=
  golang.org/x/tools/gopls@v0.6.6


# Downloads and templates
# -----------------------

[template-base]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:_update_hash_filename_}
output = ${buildout:parts-directory}/${:_buildout_section_name_}

[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}
destination = ${buildout:directory}/${:_buildout_section_name_}
output = ${:destination}

[python-language-server-requirements.txt]
<= download-base

[slapos.css.in]
<= download-base

[logo.png]
<= download-base

[instance-theia]
<= template-base
output = ${buildout:directory}/instance-theia.cfg.jinja

[instance]
<= template-base
output = ${buildout:directory}/instance.cfg

[instance-import]
<= template-base
output = ${buildout:directory}/instance-import.cfg.jinja

[instance-export]
<= template-base
output = ${buildout:directory}/instance-export.cfg.jinja

[instance-resilient]
<= download-base

[theia-common]
<= download-base
destination = ${buildout:directory}/theia_common.py

[theia-export]
<= download-base
destination = ${buildout:directory}/theia_export.py

[theia-import]
<= download-base
destination = ${buildout:directory}/theia_import.py


# Utilities
# ---------

[supervisor]
recipe = zc.recipe.egg
eggs =
  supervisor
  setuptools

[python-language-server]
version = 0.19.0
recipe = plone.recipe.command
command =
  PATH=${git:location}/bin/:$PATH  bash -c "${python3:executable} -m venv --clear ${:location} && \
    . ${:location}/bin/activate && \
    pip install -r ${python-language-server-requirements.txt:output}"
location = ${buildout:parts-directory}/${:_buildout_section_name_}
stop-on-error = true

[cli-utilities]
PATH = ${nodejs:location}/bin:${bash:location}/bin:${fish-shell:location}/bin:${tig:location}/bin:${vim:location}/bin:${tmux:location}/bin:${git:location}/bin:${curl:location}/bin:${python:location}/bin:${buildout:bin-directory}


[python-with-eggs]
recipe = zc.recipe.egg
interpreter = ${:_buildout_section_name_}
# Only generate the interpreter script to avoid conflicts with scripts
# for eggs that are also generated by another section, like slapos.toolbox
scripts = ${:interpreter}
executable = ${buildout:bin-directory}/${:interpreter}

[python-for-resiliency]
<= python-with-eggs
eggs =
  ${slapos-toolbox:eggs}
  six
  zc.buildout

[python-for-standalone]
<= python-with-eggs
eggs =
  slapos.core
needs-these-eggs-scripts-in-path =
  ${supervisor:recipe}
  ${slapos-command:recipe}


[software-info]
slapos = ${buildout:bin-directory}/slapos
python-for-resiliency = ${python-for-resiliency:executable}
python = ${python:location}/bin/python
rsync = ${rsync:location}/bin/rsync
sqlite3 = ${sqlite3:location}/bin/sqlite3
bash = ${bash:location}/bin/bash
supervisorctl = ${buildout:bin-directory}/supervisorctl
theia-export = ${theia-export:output}
theia-import = ${theia-import:output}