Last updated:
genpack.json5 is a declarative definition file for system images built with genpack. It is placed in the root directory of each artifact and consolidates package configuration, Portage settings, user/service definitions, compression methods, and more into a single file.
The format is JSON5, which supports comments, trailing commas, and other conveniences. If genpack.json5 does not exist, it falls back to genpack.json, but if both exist, an error is raised.
{
packages: ["genpack/paravirt"]
}
If name is omitted, the directory name is used automatically (with a warning).
ARTIFACT environment variable during build and is also used as the default output file name.genpack-overlay:genpack/{arch}/ and set as the Portage profile.Common profiles:
| Profile | Use Case |
|---|---|
paravirt | For QEMU/KVM virtual machines (virtio, guest agent) |
baremetal | For physical machines (BIOS/UEFI, device drivers) |
gnome/baremetal | Physical machine + GNOME desktop |
weston/paravirt | Virtual machine + Wayland (Weston) |
{name}-{arch}.squashfs--outfile CLI argument."gzip""gzip", "xz", "lzo", "none""xz" produces the smallest size but takes longer to compress. Can also be overridden with the --compression CLI argument.[]category/name).Adding a - prefix excludes the package from the list when merging with profiles or variants:
{
packages: [
"genpack/paravirt",
"app-misc/screen",
"-app-misc/unwanted-package" // Exclude from merge source
]
}
[]{
buildtime_packages: ["dev-lang/go", "dev-build/cmake"]
}
[]{}package.use.Keys are package atoms (*/* for global settings), and values are strings (space-separated) or lists:
{
use: {
"dev-lang/php": "+mysql +curl +gd +xml +zip",
"media-libs/mesa": "wayland VIDEO_CARDS: virgl",
"*/*": "python_targets_python3_12"
}
}
USE_EXPAND variables such as CPU_FLAGS_X86:, VIDEO_CARDS:, AMDGPU_TARGETS:, and APACHE2_MODULES: are also configured through this field.
{}package.accept_keywords.When the value is null, it means no keyword restriction (the standard pattern for accepting testing versions):
{
accept_keywords: {
"dev-util/debootstrap": null, // Accept ~arch
"app-misc/package": "~amd64", // Specific keyword
"app-misc/other": ["~amd64", "**"] // Multiple keywords
}
}
[]package.mask. Used for purposes such as blocking versions above a certain threshold.{
mask: [">=dev-db/mysql-8"]
}
{}package.license.{
license: {
"sys-kernel/linux-firmware": "linux-fw-redistributable",
"www-client/google-chrome": "google-chrome"
}
}
{}package.env. Specify the name of a configuration file in Portage's env/ directory.{
env: {
"sci-libs/pytorch": "torch_cuda.conf"
}
}
[]{
users: [
"simpleuser",
{
name: "advanceduser",
uid: 1000,
home: "/home/advanceduser",
shell: "/bin/bash",
initial_group: "users",
additional_groups: ["wheel", "video", "audio"],
create_home: true,
empty_password: true
}
]
}
Object format properties:
| Property | Type | Default | Description |
|---|---|---|---|
name | string | (required) | Username |
uid | integer | (auto) | User ID |
comment | string | GECOS field | |
home | string | Home directory | |
shell | string | Login shell | |
initial_group | string | Primary group | |
additional_groups | string | string[] | Additional groups | |
create_home | boolean | true | Whether to create the home directory |
empty_password | boolean | false | Whether to allow an empty password |
[]{
groups: [
"customgroup",
{ name: "groupwithgid", gid: 1002 }
]
}
[]{
services: [
"sshd",
"apache2",
"fstrim.timer",
"[email protected]"
]
}
[]{
setup_commands: [
"sed -i 's/-D SSL //' /etc/conf.d/apache2",
"mkdir -p /var/www/localhost/htdocs"
]
}
--independent-binpkgs CLI option.{
circulardep_breaker: {
packages: ["media-libs/freetype", "media-libs/harfbuzz"],
use: "-truetype -harfbuzz"
}
}
The packages specified in packages are first installed with the USE flags specified in use, and then rebuilt with the correct flags during the subsequent normal build.
{}|), and values are objects containing fields to be merged.Only the settings for keys matching the current machine's architecture (uname -m) are merged.
{
arch: {
x86_64: {
packages: ["app-misc/x86-specific"],
use: {
"media-video/ffmpeg": "CPU_FLAGS_X86: avx avx2 sse4_2"
}
},
aarch64: {
accept_keywords: {
"app-emulation/qemu-guest-agent": null
}
}
}
}
Mergeable fields: packages, buildtime_packages, accept_keywords, use, mask, license, env, binpkg_excludes, setup_commands, services
{}--variant CLI argument.{
packages: ["genpack/gnome"],
services: ["gdm"],
variants: {
paravirt: {
// packages are merged with the parent definition
packages: ["-x11-drivers/nvidia-drivers"],
use: {
"media-libs/mesa": "VIDEO_CARDS: virgl"
}
},
cuda: {
packages: ["x11-drivers/nvidia-drivers"],
use: {
"sci-libs/pytorch": "CUDA_TARGETS: sm_89"
}
}
}
}
Within a variant, most top-level fields including name, profile, and outfile can be overridden or merged. Additionally, arch can be included within a variant.
--variant is not specified on the CLI. An error is raised if the specified variant does not exist in variants.Settings in genpack.json5 are merged in the following order:
arch are mergedvariants are merged (including arch within the variant)Behavior of list-type fields during merging:
packages: Elements with a - prefix are removed from the existing list. Others are added without duplicatesbuildtime_packages, mask, services: Added without duplicatesaccept_keywords, use, license, env: Overwritten on a per-key basisThe following hyphenated names are deprecated, and using them will result in an error:
| Deprecated Name | Current Name |
|---|---|
buildtime-packages | buildtime_packages |
binpkg-exclude | binpkg_excludes |
circulardep-breaker | circulardep_breaker |
Within user objects, hyphenated names are still accepted for compatibility:
create-home → create_homeinitial-group → initial_groupadditional-groups → additional_groupsempty-password → empty_password{
// Basic information
name: "nextcloud",
profile: "paravirt",
compression: "xz",
// Packages
packages: [
"genpack/paravirt",
"www-apps/nextcloud",
"dev-db/mysql",
"dev-lang/php",
"net-misc/redis",
"www-servers/apache"
],
buildtime_packages: [
"app-arch/rpm2targz"
],
binpkg_excludes: ["sys-kernel/gentoo-kernel"],
// Portage settings
use: {
"dev-lang/php": "mysql curl gd xml zip",
"www-servers/apache": "APACHE2_MODULES: http2 proxy proxy_fcgi"
},
accept_keywords: {
"net-vpn/frp": null
},
license: {
"net-analyzer/fping": "fping",
"dev-db/redis": "SSPL-1"
},
// Users and services
users: [
{ name: "nextcloud", uid: 1000 }
],
services: ["apache2", "mysqld", "redis"],
// Setup
setup_commands: [
"sed -i 's/-D SSL //' /etc/conf.d/apache2"
],
// Variants
variants: {
selftestable: {
profile: "weston/paravirt",
packages: ["www-client/google-chrome"],
users: [
{ name: "user", uid: 1000, empty_password: true }
]
}
}
}
This document was written based on the following repository snapshots: