export BB_REGISTRY := "registry.gitlab.com"
export BB_REGISTRY_NAMESPACE := "wunker-bunker/wunker-os"
export BB_GENISO_SECURE_BOOT_URL := "https://gitlab.com/wunker-bunker/wunker-os/-/raw/main/files/base/etc/pki/akmods/certs/akmods-wunker-bunker.der"
export BB_GENISO_ENROLLMENT_PASSWORD := "wunker"
export BB_GENISO_VARIANT := "kinoite"

build *args:
    bluebuild build {{args}}

generate-iso recipe:
    #!/usr/bin/env nu
    let recipe = open {{ recipe }}
        | default [] alt-tags
        | select name alt-tags
    let tag = if ($recipe.alt-tags | is-empty) {
        'latest'
    } else {
        $recipe.alt-tags | first
    }
    let name = $recipe.name
    let image = $'(
            $env.BB_REGISTRY
        )/(
            $env.BB_REGISTRY_NAMESPACE
        )/(
            $name
        ):($tag)'
    (^bluebuild
        generate-iso
        --iso-name $'($name)-($tag).iso'
        --output-dir .iso/
        image $image)

generate-secureboot-key:
    openssl req -config ./openssl.cnf \
        -new -x509 -newkey rsa:2048 \
        -nodes -days 36500 -outform DER \
        -keyout ./.secure-files/MOK.priv \
        -out ./files/base/etc/pki/akmods/certs/akmods-wunker-bunker.der
