🚧 wip: fixup the vm, add a wip vagrantfile just in case

Signed-off-by: dyn <oss+dyn@xtrm.me>
This commit is contained in:
dyn
2025-12-17 01:27:04 +01:00
parent ab440e31c0
commit 78051f16d8
5 changed files with 60 additions and 44 deletions

View File

@ -1,3 +1,5 @@
echo "192.168.56.110 app1.com" | sudo tee -a "/etc/hosts" cat <<EOF | sudo tee /etc/hosts
echo "192.168.56.110 app2.com" | sudo tee -a "/etc/hosts" 192.168.56.110 app1.com
echo "192.168.56.110 app3.com" | sudo tee -a "/etc/hosts" 192.168.56.110 app2.com
192.168.56.110 app3.com
EOF

0
p3/scripts/setup-hostfile.sh Normal file → Executable file
View File

29
vm/Vagrantfile vendored
View File

@ -2,12 +2,33 @@
# vi: set ft=ruby : # vi: set ft=ruby :
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.box = "generic/debian12" config.vm.box = "debian/bookworm64"
config.vm.box_version = "4.3.12"
config.vm.network "public_network" config.vm.network "public_network"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../", "/home/vagrant/iot", owner: "vagrant", group: "vagrant"
config.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
vb.cpus = 4
vb.gui = false
end
config.vm.provision "shell", inline: <<-SHELL config.vm.provision "shell", inline: <<-SHELL
apt-get update -y apt update
apt-get install -y git curl apt install gnupg git wget curl -y
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle_vbox_2016.gpg] http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | tee /etc/apt/sources.list.d/virtualbox.list
wget -O- -q https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmour -o /usr/share/keyrings/oracle_vbox_2016.gpg
apt update && apt install virtualbox-7.0 -y
usermod -aG vboxusers vagrant
# export _VBVER=$(VBoxManage --version | cut -dr -f1)
# wget https://download.virtualbox.org/virtualbox/$_VBVER/Oracle_VM_VirtualBox_Extension_Pack-$_VBVER.vbox-extpack
# yes | VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-$_VBVER.vbox-extpack
#
# wget -O - https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list
# apt update && apt install vagrant -y
SHELL SHELL
end end

View File

@ -20,20 +20,10 @@
"flakes" "flakes"
]; ];
networking.hosts = {
"192.168.56.110" = [
"app1.com"
"app2.com"
"app3.com"
];
};
# Since `fileSystems` is ignored by nixos-generators, we need to be creative # Since `fileSystems` is ignored by nixos-generators, we need to be creative
systemd.services.mount-iot = { systemd.services.mount-iot = {
description = "Mount the IOT shared folder"; description = "Mount the IOT shared folder";
# fstab entry:
# host0 /wherever 9p trans=virtio,version=9p2000.L 0 0
script = '' script = ''
mkdir -p /iot mkdir -p /iot
/run/wrappers/bin/mount -t 9p -o trans=virtio,version=9p2000.L host0 /iot /run/wrappers/bin/mount -t 9p -o trans=virtio,version=9p2000.L host0 /iot
@ -48,26 +38,19 @@
}; };
}; };
users.users.root = { users.users = {
password = "toor"; root.password = "toor";
shell = pkgs.zsh; user = {
extraGroups = [ password = "iot";
"wheel" isNormalUser = true;
"libvirtd" extraGroups = [ "wheel" "docker" "libvirt" ];
]; };
}; };
users.users.adjoly = {
password = "test";
shell = pkgs.fish;
extraGroups = [
"wheel"
"libvirtd"
];
isNormalUser = true;
};
programs.fish.enable = true;
services = { services = {
k3s = {
enable = true;
};
getty.autologinUser = "root"; getty.autologinUser = "root";
openssh = { openssh = {
enable = true; enable = true;
@ -85,7 +68,13 @@
variant = "us"; variant = "us";
}; };
}; };
displayManager.gdm.enable = true; displayManager = {
gdm.enable = true;
autoLogin = {
enable = true;
user = "test";
};
};
desktopManager.gnome.enable = true; desktopManager.gnome.enable = true;
libinput.enable = true; libinput.enable = true;
}; };
@ -93,7 +82,7 @@
enable = true; enable = true;
enable32Bit = true; enable32Bit = true;
}; };
virtualisation.virtualbox.host.enable = true; virtualisation.docker.enable = true;
boot.kernelParams = [ "kvm.enable_virt_at_load=0" ]; boot.kernelParams = [ "kvm.enable_virt_at_load=0" ];
programs = { programs = {
@ -110,12 +99,15 @@
systemPackages = with pkgs; [ systemPackages = with pkgs; [
librewolf librewolf
bindfs bindfs
vagrant
git git
zip zip
neovim neovim
eza eza
bat bat
vagrant
k3d
kubectl
]; ];
}; };

View File

@ -60,11 +60,12 @@
let let
scriptName = "run-${hostname}-vm"; scriptName = "run-${hostname}-vm";
script = pkgs.writeShellScriptBin "${scriptName}" '' script = pkgs.writeShellScriptBin "${scriptName}" ''
${selfPkgs.vm}/bin/run-${hostname}-vm \ set -x
source ${selfPkgs.vm}/bin/run-${hostname}-vm \
-enable-kvm \ -enable-kvm \
-m 8G \ -m 8G \
-smp 4\ -smp 4 \
-cpu host \ -cpu host \
-virtfs local,path=$(${pkgs.coreutils}/bin/pwd)/..,mount_tag=host0,security_model=mapped-xattr,id=host0 -virtfs local,path=$(${pkgs.coreutils}/bin/pwd)/..,mount_tag=host0,security_model=mapped-xattr,id=host0
''; '';
in in
@ -80,9 +81,9 @@
${selfPkgs.vm}/bin/run-${hostname}-vm \ ${selfPkgs.vm}/bin/run-${hostname}-vm \
-enable-kvm \ -enable-kvm \
-nographic \ -nographic \
-m 8G \ -m 8G \
-smp 4 \ -smp 4 \
-cpu host \ -cpu host \
-virtfs local,path=$(${pkgs.coreutils}/bin/pwd)/..,mount_tag=host0,security_model=mapped-xattr,id=host0 -virtfs local,path=$(${pkgs.coreutils}/bin/pwd)/..,mount_tag=host0,security_model=mapped-xattr,id=host0
''; '';
in in