Hyperv Debian + UEFI

This commit is contained in:
Greg Hellings
2023-12-30 05:37:32 +00:00
parent 76abdb9132
commit b11669345e
112 changed files with 468 additions and 850 deletions
+4 -6
View File
@@ -29,14 +29,12 @@ iso = {
checksum = "${sha}"
}
boot_command = [
"<tab><wait> net.ifnames=0<wait> <wait>bi<wait>osdevnames=0<enter>",
"<wait120>", # Wait for system to come up?
"curl<wait> -o<wait> /tmp/install.sh<wait> http://<wait>{{ .HTTPIP }}<wait>:{{ .HTTPPort }}/<wait>install.sh<enter>",
"curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>",
"<wait>",
"sudo<wait> bash<wait> /tmp/install.sh<wait> {{ .HTTPPort }}<wait> {{ .HTTPIP }}<wait><enter>"
"sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}<enter>"
]
http_directory = "distros/nixos/23.05/http/"
boot_wait = "5s"
http_directory = "distros/nixos/23.11/http/"
boot_wait = "60s"
EOF
rm -r "${tmp}"
+6 -4
View File
@@ -3,7 +3,7 @@
{
imports = [
./hardware-configuration.nix
#PROVIDER_PLACEHOLDER
./guest-agent.nix
];
system.stateVersion = "23.11";
@@ -37,9 +37,11 @@
}
];
boot.loader.grub = {
enable = true;
devices = [ "@BOOT_DEVICE@" ];
boot.loader = {
systemd-boot = {
enable = true;
};
efi.canTouchEfiVariables = true;
};
networking = {
hostName = "vagrant";
+1
View File
@@ -0,0 +1 @@
ga-qemu.nix
@@ -0,0 +1,4 @@
{...}:
{
virtualisation.hypervGuest.enable = true;
}
+7
View File
@@ -0,0 +1,7 @@
{...}:
{
virtualisation.virtualbox.guest = {
enable = true;
x11 = false;
};
}
+4
View File
@@ -0,0 +1,4 @@
{...}:
{
services.qemuGuest.enable = true;
}
+7
View File
@@ -0,0 +1,7 @@
{...}:
{
virtualisation.vmware.guest = {
enable = true;
headless = false;
}
}
+22 -7
View File
@@ -15,30 +15,42 @@ fi
# The sed bit is just to strip out the extra fluff, like comments
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk}
o # create new DOS partition table
g # create new GPT partition table
n # new
p # primary partition
1 # part number
# default partition number
# default start
+512M # size
t # set type
1 # EFI system partition
n # second partition
# default partition number
# start at first free sector
# default to full disk
p # print, for debugging
w # write the partition table and exit
EOF
sleep 10 # Let me at least read it!
#t # set partition type
#1 # on partition 1
#4 # BIOS boot
# Format and mount partitions
mkfs.ext4 -L root "${disk}1"
mkfs.vfat "${disk}1"
mkfs.ext4 "${disk}2"
mount "${disk}1" /mnt
mount "${disk}2" /mnt
mkdir -p /mnt/boot
mount "${disk}1" /mnt/boot
# Bootstrap system
virt="$(systemd-detect-virt)"
nixos-generate-config --root /mnt
curl -o /mnt/etc/nixos/configuration.nix "http://${host}:${port}/configuration.nix"
curl -o /mnt/etc/nixos/flake.nix "http://${host}:${port}/flake.nix"
curl -o /mnt/etc/nixos/guest-agent.nix "http://${host}:${port}/ga-${virt}.nix"
sed -i -E -e "s,@BOOT_DEVICE@,${disk}," /mnt/etc/nixos/configuration.nix
sed -i -E -e 's,(.*device = "/dev/disk/).*(".*),\1by-label/root\2,' /mnt/etc/nixos/hardware-configuration.nix
nixos-install --no-root-password --flake "/mnt/etc/nixos/#vagrant"
# Run stuff in the chroot
@@ -46,4 +58,7 @@ curl -o /mnt/root/in-chroot.sh "http://${host}:${port}/in-chroot.sh"
nixos-enter --root /mnt -c 'bash /root/in-chroot.sh'
rm /mnt/root/in-chroot.sh
reboot
umount /mnt/boot
umount /mnt
efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')"
reboot
+1 -11
View File
@@ -1,12 +1,2 @@
#!/usr/bin/env bash
set -ex
sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix
cat << EOF > /etc/nixos/guest-agent.nix
{...}:
{
services.qemuGuest.enable = true;
}
EOF
chown vagrant:vagrant /etc/nixos/guest-agent.nix
nixos-rebuild switch
set -ex
+1 -14
View File
@@ -1,15 +1,2 @@
#!/usr/bin/env bash
set -ex
sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix
cat << EOF > /etc/nixos/guest-agent.nix
{...}:
{
virtualisation.virtualbox.guest = {
enable = true;
x11 = false;
};
}
EOF
chown vagrant:vagrant /etc/nixos/guest-agent.nix
nixos-rebuild switch
set -ex
+1 -14
View File
@@ -1,15 +1,2 @@
#!/usr/bin/env bash
set -ex
sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix
cat << EOF > /etc/nixos/guest-agent.nix
{...}:
{
virtualisation.vmware.guest = {
enable = true;
headless = false;
};
}
EOF
chown vagrant:vagrant /etc/nixos/guest-agent.nix
nixos-rebuild switch
set -ex