🚧 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"
echo "192.168.56.110 app2.com" | sudo tee -a "/etc/hosts"
echo "192.168.56.110 app3.com" | sudo tee -a "/etc/hosts"
cat <<EOF | sudo tee /etc/hosts
192.168.56.110 app1.com
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 :
Vagrant.configure("2") do |config|
config.vm.box = "generic/debian12"
config.vm.box_version = "4.3.12"
config.vm.box = "debian/bookworm64"
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
apt-get update -y
apt-get install -y git curl
apt update
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
end

View File

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

View File

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