Skip to content

Conversation

@gmpinder
Copy link
Member

@gmpinder gmpinder commented Dec 22, 2025

This PR sets up the schema for a new functionality that would allow users to have a module be conditionally executed. Both build-time and template-time on the host.

My main reason for wanting to create something like this was to help with maintaining recipes for various distros and versions. This would allow users to consolidate all their modules for say installing Nvidia drivers for all of their distros into a single recipe module file. Or if you have steps for signing a kernel module (like we do in base-images), having a host-file.exists check for the step that signs modules will be useful for allowing other users/developers that do not have the signing key to build our images locally without it.

Examples

Build-time

Only runs on fedora:

type: dnf
if:
  os-release:
    ID: fedora
install:
  packages:
    - git

Runs based on the os/version:

modules:
  - type: script
    if:
      os-release:
        ID: fedora
        VERSION: 
          - 43
          - 42
    scripts:
      - fedora/nvidiadrivers.sh
  - type: script
    if:
      os-release:
        ID: ubuntu
        VERSION:
          - 24.04
          - 24.10
          - 25.04
          - 25.10
    scripts:
      - ubuntu/nvidiadrivers.sh

Evaluate a shell expression:

type: script
if: '[ -f /some/file ] && command -v git'
snippets:
  - echo "Only runs if /some/file exists and the git command exists"

Template-time

Only runs if the private key exists:

  - type: script
    env:
      PUBLIC_KEY_DER_PATH: /etc/pki/akmods/certs/akmods-blue-build.der
    if:
      host-file:
        exists: ./MOK.priv
    secrets:
      - type: file
        source: ./MOK.priv
        mount: 
          type: file
          destination: /tmp/certs/private_key.priv
    scripts:
      - signkernel.sh

@gmpinder gmpinder requested a review from xynydev as a code owner December 22, 2025 18:43
@gmpinder gmpinder self-assigned this Dec 22, 2025
@gmpinder
Copy link
Member Author

I have yet to implement this in the CLI. Just thought I should show the schema we could use before I continue.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 23, 2025

Deploying bluebuild-schema with  Cloudflare Pages  Cloudflare Pages

Latest commit: 30258e6
Status: ✅  Deploy successful!
Preview URL: https://8e2d4359.schema-e29.pages.dev
Branch Preview URL: https://module-if.schema-e29.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants