diff --git a/.gitignore b/.gitignore index af167f6..c78d4d0 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,6 @@ dkms.conf # # # ArchPkgbuild # # # package/arch/* !package/arch/PKGBUILD + +# # # Vagrant # # # +**/.vagrant diff --git a/README.md b/README.md index 17490d3..82ea6bb 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,9 @@ library, meaning a rock-solid foundation to build on. * `wl-clipboard` (screenshot & clipboard) * `brightnessctl` (brightness control via waybar) +### Using the Vagrant development environment +TODO: Finish this section + ### Building and installing * Clone the repo diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..765687b --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,106 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +module LocalCommand + class Config < Vagrant.plugin("2", :config) + attr_accessor :command + end + + class Plugin < Vagrant.plugin("2") + name "local_shell" + + config(:local_shell, :provisioner) do + Config + end + + provisioner(:local_shell) do + Provisioner + end + end + + class Provisioner < Vagrant.plugin("2", :provisioner) + def provision + result = system "#{config.command}" + end + end +end + +Vagrant.configure("2") do |config| + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development devenvment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.define "devenv" + config.vm.box = "generic/arch" + config.vm.hostname = "bonsai-devenv" + + # Configure libvirt for 3d accelerated graphical session. + config.vm.provider :libvirt do |libvirt| + libvirt.graphics_type = "spice" + libvirt.video_accel3d = true + libvirt.video_type = "virtio" + libvirt.graphics_ip = nil + libvirt.graphics_port = nil + libvirt.uuid = "60fa5b18-e4d6-47a4-af7a-023d3d34bfaa" + libvirt.uri = "qemu:///system" + end + + # Share working directory with devenv. + config.vm.synced_folder ".", "/vagrant_data" + + # Various provisioners for working with the devenv. + config.vm.provision "connect", type: "local_shell", run: "always" do |p| + p.command = "virt-viewer -ac qemu:///system --uuid 60fa5b18-e4d6-47a4-af7a-023d3d34bfaa &" + end + + config.vm.provision "prepare_box", type: "shell", run: "once" do |p| + p.path = "devenv/prepare_box.sh" + p.privileged = true + end + + config.vm.provision "install_compile_deps", type: "shell", run: "once" do |p| + p.path = "devenv/install_compile_deps.sh" + p.privileged = true + end + + config.vm.provision "install_runtime_deps", type: "shell", run: "once" do |p| + p.path = "devenv/install_runtime_deps.sh" + p.privileged = true + end + + config.vm.provision "prepare_git", type: "shell", run: "never" do |p| + p.path = "devenv/project_prepare_git.sh" + p.privileged = false + end + + config.vm.provision "prepare_local", type: "shell", run: "never" do |p| + p.path = "devenv/project_prepare_local.sh" + p.privileged = false + end + + config.vm.provision "build", type: "shell", run: "never" do |p| + p.path = "devenv/project_build.sh" + p.privileged = false + end + + config.vm.provision "update", type: "shell", run: "never" do |p| + p.path = "devenv/project_update.sh" + p.privileged = false + end + + config.vm.provision "run", type: "shell", run: "never" do |p| + p.path = "devenv/project_run.sh" + p.privileged = false + end + + config.vm.provision "kill", type: "shell", run: "never" do |p| + p.path = "devenv/project_kill.sh" + p.privileged = false + end + + config.vm.provision "clean", type: "shell", run: "never" do |p| + p.path = "devenv/project_clean.sh" + p.privileged = false + end +end diff --git a/devenv/install_compile_deps.sh b/devenv/install_compile_deps.sh new file mode 100755 index 0000000..3b66fd4 --- /dev/null +++ b/devenv/install_compile_deps.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +install() { + pacman -S --noconfirm $@ +} + +concat() { + local -n in=$1 + for dep in ${in[@]}; do + deps="$deps $dep" + done + echo $deps +} + +dependencies=( + base-devel + gdb + git + meson + libinput + libevdev + systemd-libs + libxkbcommon + mesa + vulkan-headers + libdrm + wayland + wayland-utils + wayland-protocols + xdg-desktop-portal + xdg-desktop-portal-wlr + pixman + cairo + seatd + xcb-util + xcb-util-renderutil + xcb-util-wm + xcb-util-errors + xorg-xwayland + glslang + ffmpeg + rsync +) + +install $(concat dependencies) + +install_wlroots_latest() { + git clone https://gitlab.freedesktop.org/wlroots/wlroots.git /root/wlroots + cd /root/wlroots + meson builddir + meson compile -C builddir + meson install -C builddir +} + +install_wlroots_latest diff --git a/devenv/install_runtime_deps.sh b/devenv/install_runtime_deps.sh new file mode 100755 index 0000000..cd6d3aa --- /dev/null +++ b/devenv/install_runtime_deps.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +install() { + pacman -S --noconfirm $@ +} + +concat() { + local -n in=$1 + for dep in ${in[@]}; do + deps="$deps $dep" + done + echo $deps +} + +dependencies=( + swaybg + swaylock + bemenu-wayland + waybar + slurp + grim + wl-clipboard + brightnessctl +) + +install $(concat dependencies) diff --git a/devenv/prepare_box.sh b/devenv/prepare_box.sh new file mode 100755 index 0000000..281a912 --- /dev/null +++ b/devenv/prepare_box.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +update () { + pacman -Syu --noconfirm +} + +update diff --git a/devenv/project_build.sh b/devenv/project_build.sh new file mode 100644 index 0000000..9fbe1fb --- /dev/null +++ b/devenv/project_build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +[ ! -d /home/vagrant/bonsai ] && echo "Run prepare_* first." && exit 1 + +cd /home/vagrant/bonsai +meson compile -C builddir/ diff --git a/devenv/project_clean.sh b/devenv/project_clean.sh new file mode 100644 index 0000000..cf9a552 --- /dev/null +++ b/devenv/project_clean.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +[ ! -d /home/vagrant/bonsai ] && echo "Nothing to clean." && exit 0 + +cd /home/vagrant/bonsai + +[ ! -d builddir ] && echo "Nothing to clean." && exit 0 + +rm -rf builddir diff --git a/devenv/project_kill.sh b/devenv/project_kill.sh new file mode 100644 index 0000000..a60eee2 --- /dev/null +++ b/devenv/project_kill.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +killall bonsai diff --git a/devenv/project_prepare_git.sh b/devenv/project_prepare_git.sh new file mode 100644 index 0000000..e93ba71 --- /dev/null +++ b/devenv/project_prepare_git.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +[ ! -d /home/vagrant/bonsai ] && git clone https://github.com/vilfa/bonsai.git /home/vagrant/bonsai +cd /home/vagrant/bonsai +[ ! -d builddir ] && PKG_CONFIG_PATH=/usr/local/lib/pkgconfig meson builddir/ diff --git a/devenv/project_prepare_local.sh b/devenv/project_prepare_local.sh new file mode 100644 index 0000000..71dc773 --- /dev/null +++ b/devenv/project_prepare_local.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +[ -d /home/vagrant/bonsai ] && rm -rf /home/vagrant/bonsai +mkdir /home/vagrant/bonsai && cd /home/vagrant/bonsai +rsync -vh --no-compress --progress --info=progress -r \ + /vagrant_data/* /home/vagrant/bonsai \ + --exclude=".*" --exclude="builddir" + +cd /home/vagrant/bonsai +[ ! -d builddir ] && PKG_CONFIG_PATH=/usr/local/lib/pkgconfig meson builddir/ diff --git a/devenv/project_run.sh b/devenv/project_run.sh new file mode 100644 index 0000000..b99e849 --- /dev/null +++ b/devenv/project_run.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +[ ! -d /home/vagrant/bonsai ] && echo "Run prepare_* first." && exit 1 + +cd /home/vagrant/bonsai + +[ ! -f builddir/bonsai/bonsai ] && echo "Run build first." && exit 1 + +tty=$(who | grep tty) +if [[ "$tty" ]]; then + tty="/dev/$(who | grep tty | tr -s ' ' | cut -d ' ' -f 2)" + echo "Open graphical console is $tty." + echo "Running bonsai in the open graphical session is currently unsupported." + echo "Run it manually with `cd /home/vagrant/bonsai && ./builddir/bonsai/bonsai`." + # TODO: Run bonsai in the open graphical console. + # setsid bash -c "export XDG_SEAT=seat0 && exec /home/vagrant/bonsai/builddir/bonsai/bonsai <> $tty >&0 2>&1" + # sudo openvt -svfc 1 -- bash -c "export XDG_SEAT=seat0 && exec /home/vagrant/bonsai/builddir/bonsai" +else + echo "Login in the graphical session first (vagrant:vagrant)." + exit 1 +fi diff --git a/devenv/project_update.sh b/devenv/project_update.sh new file mode 100644 index 0000000..55d4013 --- /dev/null +++ b/devenv/project_update.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +[ ! -d /home/vagrant/bonsai ] && echo "Run prepare_* first." && exit 1 +rsync -vh --no-compress --progress --info=progress -r \ + /vagrant_data/* /home/vagrant/bonsai \ + --exclude=".*" --exclude="builddir"