Skip to content

Latest commit

 

History

History
84 lines (74 loc) · 3.1 KB

README.org

File metadata and controls

84 lines (74 loc) · 3.1 KB

rules_packer

Installation

Rules

Configuration

Linux headless

packer_configure(
    packer_version = "1.8.6",
    qemu_version = "wip", # TODO: is it possible to load our own qemu like this?
    global_substitutions = {
        '{headless}': "true",
        '{http_dir}': ".",
        '{accel}': "kvm",
        '{vga}': "qxl",
        '{display}': "none",
        '{cpu}': "Cascadelake-Server-v4" # NOTE: change this to whatever your virtualization target is
    },
    debug = True
)

MacOS

packer_configure(
    packer_version = "1.8.6",
    qemu_version = "wip", # TODO: is it possible to load our own qemu like this?
    global_substitutions = {
        '{http_dir}': ".",
        '{accel}': "tcg", # TODO: confirm hvm works here
        '{vga}': "cirrus",
        '{display}': "cocoa",
        '{cpu}': "Cascadelake-Server-v4"
    },
    debug = True # This enables better errors in packer, but is not needed (PACKER_LOG=1)
)

Enabling non-headless (GUI) windows on the host system

Linux

As of now, this doesn’t seem to work

MacOS

using cocoa and cirrus for the qemuargs’s display and vga arguments appears to let this work on MacOS

Usage

github action to publish this needs to be set up in order for the usual http_archive bazel installation to work

load("@com_github_rules_packer//:packer_config.bzl", "packer_configure")

packer_configure(
    packer_version = "1.8.6",
    qemu_version = "wip", # TODO: is it possible to load our own qemu like this?
    global_substitutions = {
        '"{$foo}"': "bar",
        '{http_dir}': ".",
        '{accel}': "kvm",
        '{vga}': "qxl",
        '{display}': "gtk",
        '{cpu}': "Cascadelake-Server-v4"
    },
    debug = True
)


load("@com_github_rules_packer//:packer_dependencies.bzl", "packer_dependencies")

packer_dependencies()

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")

aspect_bazel_lib_dependencies()

Rule usage

There are several special variables and facilities for getting the packer experience to be more ergonomic

interpolationmeaningwhere
$(location depfile)any file in deps can be accessed this wayin substitutions or vars or env
$(location output)the output directory (packer’s output_directory)in substitutions or vars
{iso_sha}
{input_img}the target path of the input_img argumentin substitutions or vars or env
{iso}the substitution of the input_imgin your packerfile or varfile