### Example of using custom modules in blue-build Source: https://blue-build.org/how-to/module-repository Demonstrates how to specify a custom module repository as a source for modules within a blue-build configuration. This allows you to utilize modules from your own OCI image repository. ```yaml modules: - type: # supports using tags like `:latest` too source: ghcr.io/octocat/bluebuild-modules list: - gec - gec - gec ``` -------------------------------- ### Configure multiple modules in YAML Source: https://blue-build.org/how-to/multiple-files This YAML snippet shows how to define multiple modules within a single external file using the 'modules:' key. It includes examples for 'signing', 'files', 'fonts', and importing another configuration file ('common-packages.yml'). ```yaml --- # yaml-language-server: $schema=https://schema.blue-build.org/module-list-v1.json modules: - type: signing - type: files files: - usr: /usr - type: fonts fonts: nerd-fonts: - Hack - from-file: common-packages.yml ``` -------------------------------- ### Run BlueBuild Gnome Extensions Module with JSON Configuration in Containerfile Source: https://blue-build.org/how-to/minimal-setup This snippet demonstrates how to run the `gnome-extensions` BlueBuild module within a Containerfile. It uses `run_module.sh` with a JSON string specifying the extensions to install. It also includes mounts for module source code and build scripts. ```dockerfile # Run BlueBuild's gnome-extensions module RUN \ # add in the module source code --mount=type=bind,from=ghcr.io/blue-build/modules:latest,src=/modules,dst=/tmp/modules,rw \ # add in the script that sets up the module run environment --mount=type=bind,from=ghcr.io/blue-build/cli/build-scripts:latest,src=/scripts/,dst=/tmp/scripts/ \ # run the module /tmp/scripts/run_module.sh 'gnome-extensions' \ '{"type":"gnome-extensions","install":["Vitals","GSConnect","Burn My Windows","PaperWM","Gnome 4x UI Improvements"]}' ``` -------------------------------- ### Run BlueBuild Gnome Extensions Module with YAML Configuration in Containerfile Source: https://blue-build.org/how-to/minimal-setup This snippet shows how to run the `gnome-extensions` BlueBuild module using a YAML configuration within a Containerfile. It leverages `yq` to convert the YAML configuration into a JSON string expected by `run_module.sh`. Ensure `yq` is installed and append `\n\` to each line of the YAML string. ```dockerfile # run the module config=$'\ type: gnome-extensions \n\ install: \n\ - Vitals # https://extensions.gnome.org/extension/1460/vitals/ \n\ - GSConnect # https://extensions.gnome.org/extension/1319/gsconnect/ \n\ - Burn My Windows # https://extensions.gnome.org/extension/4679/burn-my-windows/ \n\ - PaperWM # https://extensions.gnome.org/extension/6099/paperwm/ \n\ - Gnome 4x UI Improvements # https://extensions.gnome.org/extension/4158/gnome-40-ui-improvements/ \n\ ' && \ /tmp/scripts/run_module.sh "$(echo "$config" | yq eval '.type')" "$(echo "$config" | yq eval -o=j -I=0)" ``` -------------------------------- ### Switch OS to locally built image with BlueBuild CLI Source: https://blue-build.org/how-to/local The `switch` command is a workflow command that builds an image from a recipe, exports it as a `.tar.gz` file, and then uses `rpm-ostree` to rebase or upgrade the current operating system with the locally built image. An immediate reboot can be triggered with the `--reboot` argument. ```bash bluebuild switch ./recipes/recipe.yml ``` ```bash bluebuild switch --reboot ./recipes/recipe.yml ``` -------------------------------- ### Read configuration in a module script Source: https://blue-build.org/how-to/making-modules Demonstrates how to read configuration data passed as a JSON string to a bash module script. It shows how to extract single variables and arrays using `jq` and environment variables. ```bash #!/usr/bin/env bash set -euo pipefail # read a single variable from the configuration # `try` makes the command output 'null' if the key is not found, otherwise it will error out and the build will fail # the `.["var"]` syntax is optional and could be replaced with the less safe and more error-prone `.var` syntax VAR=$(echo "$1" | jq -r 'try .["var"]') echo "$VAR" # read an array from the configuration get_json_array ARRAY 'try .["array"][]' "$1" # loop over the array for THING in "${ARRAY[@]}"; do echo "$THING" done ``` -------------------------------- ### Generate skopeo key pair for cosign Source: https://blue-build.org/how-to/cosign Generates a new public and private key pair for container signing using skopeo, compatible with cosign. This command creates `cosign.pub` and `cosign.private` files. Ensure no password is set for the private key as it will be used in automated workflows. ```bash # generates cosign.pub and cosign.private skopeo generate-sigstore-key --output-prefix cosign ``` -------------------------------- ### Define KDE Image Recipe Source: https://blue-build.org/how-to/multiple-images This YAML snippet defines a recipe for a KDE Plasma version of a custom OS image. It includes a unique name, description, and specifies a different base image suitable for KDE. This allows for distinct image builds from the same project. ```yaml name: weird-kde description: This is the LDE Plasma version of my personal OS image. base-image: ghcr.io/ublue-os/kinoite-main # ... ``` -------------------------------- ### Define GNOME Image Recipe Source: https://blue-build.org/how-to/multiple-images This YAML snippet defines a recipe for a GNOME version of a custom OS image. It specifies the image name, a description, and the base image to use. Ensure the name is unique to avoid conflicts. ```yaml name: weird-gnome description: This is the GNOME version of my personal OS image. base-image: ghcr.io/ublue-os/silverblue-main # ... ``` -------------------------------- ### Configure a single module in YAML Source: https://blue-build.org/how-to/multiple-files This YAML snippet demonstrates how to configure a single module, specifically 'default-flatpaks' with the 'org.blender.Blender' package, in an external file. It uses a schema for validation. ```yaml --- # yaml-language-server: $schema=https://schema.blue-build.org/module-v1.json type: default-flatpaks system: install: - org.blender.Blender ``` -------------------------------- ### Build image from recipe with BlueBuild CLI Source: https://blue-build.org/how-to/local The `build` command compiles an image based on a provided recipe. This is useful for local testing before committing changes to a repository. The BlueBuild GitHub Action utilizes the same command, with additional options for pushing to registries. ```bash bluebuild build ./recipes/recipe.yml ``` -------------------------------- ### Generate Containerfile from recipe with BlueBuild CLI Source: https://blue-build.org/how-to/local The `generate` command creates a `Containerfile` from a `recipe.yml`. It prints to stdout by default or can write to a specified file using the `--output` argument. The `--display-full-recipe` argument can be used to show the complete recipe with all included snippets. ```bash bluebuild generate ./recipes/recipe.yml -o Containerfile ``` ```bash bluebuild generate -d ./recipes/recipe.yml ``` -------------------------------- ### Import external module configurations in recipe YAML Source: https://blue-build.org/how-to/multiple-files This YAML snippet illustrates how to include configurations from external files into your main Blue Build recipe using the 'from-file:' directive. It shows importing 'common-modules.yml' and 'common-flatpaks.yml'. ```yaml # ...rest of the recipe modules: - from-file: common-modules.yml - from-file: common-flatpaks.yml ``` -------------------------------- ### Configure Build Workflow for Multiple Recipes Source: https://blue-build.org/how-to/multiple-images This YAML snippet shows how to configure a GitHub Actions build workflow to build multiple OS images. By listing different recipe files under `jobs.bluebuild.strategy.matrix.recipe`, the workflow will execute builds for each specified recipe, enabling parallel or sequential image generation. ```yaml # ... jobs: bluebuild: strategy: matrix: recipe: - recipe-gnome.yml - recipe-kde.yml # or like this if you want to have the recipes in their own directory: # - common/gnome.yml # - common/kde.yml # ... ``` -------------------------------- ### Fetch All Git Commits Source: https://blue-build.org/how-to/sync Fetches the latest commits from all configured remote repositories, including your local repository and the newly added 'template' remote. This prepares your local repository to see the latest changes from the template. ```git git fetch --all ``` -------------------------------- ### Generate cosign key pair Source: https://blue-build.org/how-to/cosign Generates a new public and private key pair for container signing using cosign. This command creates `cosign.pub` and `cosign.key` files. Ensure no password is set for the private key as it will be used in automated workflows. ```bash # generates cosign.pub and cosign.key cosign generate-key-pair ``` -------------------------------- ### Copy yq for YAML Configuration in Containerfile Source: https://blue-build.org/how-to/minimal-setup This snippet shows how to copy the `yq` binary into your Containerfile. `yq` is used to process YAML configuration files, allowing you to pass BlueBuild module configurations in YAML format. ```dockerfile # `yq` be used to pass BlueBuild modules configuration written in yaml COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq ``` -------------------------------- ### Use a custom module in configuration Source: https://blue-build.org/how-to/making-modules This YAML snippet shows how to include a custom module in your image configuration. The custom module is referenced by its type, and options can be passed to it. ```yaml modules: - type: option: true ``` -------------------------------- ### Create an empty module script Source: https://blue-build.org/how-to/making-modules This snippet shows the basic structure for an empty bash module script. It ensures the correct shell is used and that errors within the module will cause the build to fail. ```bash #!/usr/bin/env bash set -euo pipefail ``` -------------------------------- ### Set GitHub repository secret with CLI Source: https://blue-build.org/how-to/cosign Sets a new GitHub repository secret named `SIGNING_SECRET` using the GitHub CLI. The value of the secret is populated from the contents of a specified private key file (`cosign.key` or `cosign.private`). This is an alternative to manually adding secrets via the GitHub web interface. ```bash gh secret set SIGNING_SECRET < cosign.key # or cosign.private ``` -------------------------------- ### Add Blue-Build Template as Git Remote Source: https://blue-build.org/how-to/sync Adds the blue-build/template repository as a remote named 'template' to your local repository. This allows you to fetch and merge changes from the template. ```git git remote add template https://github.com/blue-build/template.git ``` -------------------------------- ### Merge Template Changes into Repository Source: https://blue-build.org/how-to/sync Merges the 'main' branch from the 'template' remote into your current local branch. The `--allow-unrelated-histories` flag is crucial for merging repositories that do not share a common commit history. This step may require manual conflict resolution. ```git git merge template/main --allow-unrelated-histories ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.