-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a development environment setup using Vagrant. #9
- Loading branch information
Luka Vilfan
committed
Oct 3, 2022
1 parent
53b835a
commit 2382f01
Showing
13 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,6 @@ dkms.conf | |
# # # ArchPkgbuild # # # | ||
package/arch/* | ||
!package/arch/PKGBUILD | ||
|
||
# # # Vagrant # # # | ||
**/.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
update () { | ||
pacman -Syu --noconfirm | ||
} | ||
|
||
update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
killall bonsai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |