-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchlinux.pkr.hcl
More file actions
109 lines (97 loc) · 3.62 KB
/
archlinux.pkr.hcl
File metadata and controls
109 lines (97 loc) · 3.62 KB
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
locals {
# renovate: datasource=custom.html depName=archlinux-iso versioning=loose extractVersion=(^|/)(?<version>[0-9.]+)/$ registryUrl=https://geo.mirror.pkgbuild.com/iso/
archlinux_version = "2026.04.01"
}
source "qemu" "archlinux" {
iso_url = "https://geo.mirror.pkgbuild.com/iso/${local.archlinux_version}/archlinux-${local.archlinux_version}-x86_64.iso"
iso_checksum = "file:https://geo.mirror.pkgbuild.com/iso/${local.archlinux_version}/sha256sums.txt"
vga = "virtio"
cpus = 2
memory = 8192
headless = var.headless
shutdown_command = "/sbin/poweroff"
qmp_enable = var.headless
disk_discard = "unmap"
http_content = {
"/archinstall-config.json" = templatefile("${path.root}/archinstall-config.json", { path = path, hostname = "archlinux" })
"/archinstall-creds.json" = file("${path.root}/archinstall-creds.json")
"/vagrant.pub" = file("${path.root}/keys/vagrant.pub")
}
ssh_username = "root"
ssh_private_key_file = "${path.root}/keys/vagrant"
boot_wait = "1m"
boot_command = [
"curl -o /root/.ssh/authorized_keys 'http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.pub'<enter>",
]
efi_firmware_code = local.efi_firmware_code
efi_firmware_vars = local.efi_firmware_vars
qemuargs = [["-cpu", "host"], ["-serial", "stdio"]]
machine_type = var.machine_type
}
build {
sources = [
"source.qemu.archlinux"
]
provisioner "shell" {
inline = [
"sgdisk --align-end --clear --new 0:0:+1M --typecode=0:ef02 --change-name=0:'BIOS boot partition' --new 0:0:+300M --typecode=0:ef00 --change-name=0:'EFI system partition' --new 0:0:0 --typecode=0:8304 --change-name=0:'Arch Linux root' /dev/vda",
"udevadm settle",
"partprobe /dev/vda",
"udevadm settle",
"mkfs.btrfs /dev/disk/by-partlabel/$(systemd-escape 'Arch Linux root')",
"mount --mkdir -o discard,compress-force=zstd /dev/disk/by-partlabel/$(systemd-escape 'Arch Linux root') /mnt",
"mkfs.fat -F 32 -S 4096 /dev/disk/by-partlabel/$(systemd-escape 'EFI system partition')",
"mount --mkdir /dev/disk/by-partlabel/$(systemd-escape 'EFI system partition') /mnt/boot",
]
}
provisioner "shell" {
inline = [
"archinstall --config-url 'http://${build.PackerHTTPAddr}/archinstall-config.json' --creds-url 'http://${build.PackerHTTPAddr}/archinstall-creds.json' --silent --debug"
]
}
provisioner "shell" {
inline = [
"echo 'vagrant ALL=(ALL:ALL) NOPASSWD: ALL' > /mnt/etc/sudoers.d/vagrant",
"mkdir -p /mnt/root/.ssh",
"mkdir -p /mnt/home/vagrant/.ssh",
]
}
provisioner "file" {
source = "${path.root}/keys/vagrant.pub"
destination = "/mnt/root/.ssh/authorized_keys"
}
provisioner "file" {
source = "${path.root}/keys/vagrant.pub"
destination = "/mnt/home/vagrant/.ssh/authorized_keys"
}
provisioner "shell" {
inline = [
"chmod 0644 /mnt/home/vagrant/.ssh/authorized_keys",
"arch-chroot /mnt chown vagrant /home/vagrant/.ssh /home/vagrant/.ssh/authorized_keys"
]
}
provisioner "file" {
direction = "download"
destination = "${var.log_dir}/${build.PackerRunUUID}/"
source = "/var/log/archinstall/"
}
error-cleanup-provisioner "file" {
direction = "download"
destination = "${var.log_dir}/${build.PackerRunUUID}/"
source = "/var/log/archinstall/"
}
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = flatten([
local.ovmf_include,
"output-${source.name}/efivars.fd",
])
compression_level = 9
}
post-processor "vagrant-registry" {
box_tag = "gnome-shell-box/${source.name}"
version = local.version
}
}
}