Package config: flags, environment variables, extra files

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

gokr-packer \
  -update=yes \ \ \

…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:

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/
echo '-forward=loopback' > flags/

Environment variables

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

mkdir -p env/
echo 'GODEBUG=gctrace=1' > env/

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/
echo '-ldflags=-X' > buildflags/

Extra files

If your program needs extra files to be present in gokrazy’s root file system image at a specific location, you can add them with the extrafiles mechanism:

mkdir -p extrafiles/
cat > extrafiles/ <<'EOT'
http://:80 {
	root * /tmp
	file_server browse