Skip to content

radixbio/rules_packer_ext

Repository files navigation

rules_packer

Installation

Rules

Installation

# TODO http_archive line
load("@com_github_rules_packer//:packer_config.bzl", "packer_configure")
# NOTE your packer_configure targets go here
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()

Configuration

Linux (GTK window)

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

Linux headless

packer_configure(
    packer_version = "1.8.6",
    qemu_version = "wip",
    global_substitutions = {
        '{headless}': "true",
        '{http_dir}': ".",
        '{accelerator}': "kvm",
        '{vga}': "none",
        '{display}': "none",
        '{cpu}': "Cascadelake-Server-v4" # NOTE: change this to whatever your virtualization target is
    }
)

MacOS (cocoa window)

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}': ".",
        '{accelerator}': "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

You should set headless to false, and supply a VGA adapter like qxl in vga and set the display to be gtk

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}': ".",
        '{accelerator}': "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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •