gokrazy

Per-package configuration

gokrazy will arrange for each included package to be started at boot. For example, given the following packer command:

gokr-packer \
  -update=yes \
  github.com/gokrazy/hello \
  github.com/gokrazy/breakglass \
  github.com/gokrazy/serial-busybox

…gokrazy will start the hello, breakglass and serial-busybox programs.

This article shows how you can configure different aspects of individual packages.

Each bit of configuration lives in its own directory: flags, env or buildflags.

Within these directories, create a directory named after the package import path, then place your configuration in a text file: flags.txt, env.txt or buildflags.txt.

Command-line flags

The breakglass package provides emergency/debugging access to a gokrazy installation.

To enable SSH port forwardings to localhost, set the -forward flag to loopback:

mkdir -p flags/github.com/gokrazy/breakglass
echo '-forward=loopback' > flags/github.com/gokrazy/breakglass/flags.txt

Environment variables

Environment variables such as the Go runtime’s GODEBUG variable can be set as follows:

mkdir -p env/github.com/gokrazy/breakglass
echo 'GODEBUG=gctrace=1' > env/github.com/gokrazy/breakglass/env.txt

Go build flags

If you want to influence the build of the package at image-creation time (as opposed to runtime), you can specify flags to be passed to the Go build invocation.

This example overwrites the value of the world variable using the -X linker flag, which is a common technique to embed version information:

mkdir -p buildflags/github.com/gokrazy/hello
echo '-ldflags=-X main.world=Welt' > buildflags/github.com/gokrazy/hello/buildflags.txt