-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
110 lines (88 loc) · 3.26 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# frozen_string_literal: true
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
Vagrant.configure('2') do |config|
ENV['LC_ALL'] = 'en_US.UTF-8'
config.vm.box = 'generic/alpine318'
config.vm.box_version = '4.3.12'
# 16,67 mins
config.vm.boot_timeout = 1000
config.vm.hostname = 'host'
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.synced_folder './module', '/home/vagrant/module', type: "rsync"
config.vm.synced_folder './src', '/home/vagrant/src', type: "rsync"
config.vm.provider :libvirt do |libvirt|
libvirt.memory = '2048'
libvirt.cpus = 4
libvirt.default_prefix = 'Kernel'
libvirt.storage_pool_name = 'default'
libvirt.qemu_use_session = false
libvirt.keymap = 'en-us'
end
config.vm.provider 'virtualbox' do |vb|
vb.memory = '2048'
vb.cpus = 4
vb.name = 'Kernel'
vb.gui = false
vb.check_guest_additions = false
vb.customize ['modifyvm', :id, '--clipboard', 'bidirectional']
end
config.vm.provision 'shell', inline: <<-SHELL, privileged: false
# Upgrade Alpine from 3.18 to 3.21
sudo sed -i -e 's/v3\.18/v3\.21/g' /etc/apk/repositories
# Add & Upgrade packages
sudo apk upgrade -U -a --ignore linux-headers linux-virt
sudo apk add bison build-base elfutils-dev flex git htop libressl-dev linux-headers perl strace wget xz
## Bashrc tweaks ##
# Set CTRL+L to clear
echo 'bind -x "\"\C-l\":clear"' >> ~/.bashrc
# Avoid 'xterm-kitty': unknown terminal type
echo "TERM=xterm-256color" >> ~/.bashrc
sudo reboot
SHELL
if ENV['VAGRANT_KERNEL'] == 'true'
config.vm.provision 'shell', inline: <<-SHELL, privileged: false
# Download Kernel
KERNEL_VERSION="6.11"
wget --no-verbose https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${KERNEL_VERSION}.tar.xz
tar -xf linux-${KERNEL_VERSION}.tar.xz
cd linux-${KERNEL_VERSION}
# Configure & Install Kernel
make defconfig
make -j$(nproc)
sudo make modules_install
sudo make install
# Create an initramfs with new Kernel
sudo mkinitfs -o /boot/initramfs 6.11.0/
# Update bootloader
sudo sed -i -e 's|^ LINUX vmlinuz-virt| LINUX vmlinuz|' -e 's|^ INITRD initramfs-virt| INITRD initramfs|' /boot/extlinux.conf
sudo reboot
SHELL
end
if ENV['VAGRANT_CUSTOM'] == 'true'
config.vm.provision 'shell', inline: <<-SHELL, privileged: false
# Clang-format
sudo apk add clang19-extra-tools
# Checkpatch.pl
wget https://raw.githubusercontent.com/torvalds/linux/refs/heads/master/scripts/checkpatch.pl
chmod +x ./checkpatch.pl
# Omb
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"
# Add & enable rsyslog for kernel logs
sudo apk add rsyslog
sudo service rsyslog start
sudo rc-update add rsyslog default
SHELL
end
if ENV['VAGRANT_IDE'] == 'true'
config.vm.provision 'shell', inline: <<-SHELL, privileged: false
# Add neovim with custom dotfiles
sudo apk add neovim
mkdir ~/.config
git clone https://github.com/MikeHorn-git/dotfiles
cd dotfiles
make nvim
echo "alias vim=nvim" >> ~/.bashrc
SHELL
end
end