{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "/modules/akmods-v1.json",
    "type": "object",
    "properties": {
        "type": {
            "anyOf": [
                {
                    "type": "string",
                    "const": "akmods"
                },
                {
                    "type": "string",
                    "const": "akmods@v1"
                },
                {
                    "type": "string",
                    "const": "akmods@latest"
                }
            ],
            "description": "The akmods module is a tool used for managing and installing kernel modules built by Universal Blue.\nhttps://blue-build.org/reference/modules/akmods/"
        },
        "no-cache": {
            "type": "boolean",
            "default": false,
            "description": "Whether to disabling caching for this layer.\nhttps://blue-build.org/reference/module/#no-cache-optional"
        },
        "env": {
            "$ref": "#/$defs/RecordString",
            "description": "Environment variables to add for the module call."
        },
        "secrets": {
            "type": "array",
            "items": {
                "$ref": "#/$defs/Secret"
            },
            "description": "Secrets to mount for this module call."
        },
        "base": {
            "anyOf": [
                {
                    "type": "string",
                    "const": "main"
                },
                {
                    "type": "string",
                    "const": "asus"
                },
                {
                    "type": "string",
                    "const": "fsync"
                },
                {
                    "type": "string",
                    "const": "fsync-ba"
                },
                {
                    "type": "string",
                    "const": "surface"
                },
                {
                    "type": "string",
                    "const": "coreos-stable"
                },
                {
                    "type": "string",
                    "const": "coreos-testing"
                },
                {
                    "type": "string",
                    "const": "bazzite"
                }
            ],
            "default": "main",
            "description": "The kernel your images uses.\n- main: stock Fedora kernel / main and nvidia images\n- asus: asus kernel / asus images\n- fsync: fsync kernel / not used in any Universal Blue images\n- fsync-ba: fsync kernel, stable version / not used in any Universal Blue images\n- surface: surface kernel / surface images\n- coreos-stable: stock CoreOS kernel / uCore stable images\n- coreos-testing: stock CoreOS Testing kernel / uCore testing images\n- bazzite: Bazzite's kernel / bazzite images"
        },
        "install": {
            "type": "array",
            "items": {
                "type": "string"
            },
            "description": "List of akmods to install.\nSee all available akmods here: https://github.com/ublue-os/akmods#kmod-packages"
        },
        "nvidia-driver": {
            "anyOf": [
                {
                    "type": "string",
                    "const": "nvidia"
                },
                {
                    "type": "string",
                    "const": "nvidia-open"
                }
            ],
            "description": "Nvidia driver to install\n- nvidia : for the old nvidia propietary driver, compatible with Maxwell and newer cards (but not Blackwell) \n- nvidia-open : for the new kernel-open driver, to be used in Turing and newer cards"
        }
    },
    "required": [
        "type",
        "install"
    ],
    "additionalProperties": false,
    "$defs": {
        "RecordString": {
            "type": "object",
            "properties": {},
            "additionalProperties": {
                "type": "string"
            }
        },
        "Secret": {
            "oneOf": [
                {
                    "$ref": "#/$defs/SecretEnv"
                },
                {
                    "$ref": "#/$defs/SecretFile"
                },
                {
                    "$ref": "#/$defs/SecretExec"
                },
                {
                    "$ref": "#/$defs/SecretSsh"
                }
            ]
        },
        "SecretEnv": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "const": "env",
                    "description": "A secret pulled from an environment variable."
                },
                "name": {
                    "type": "string",
                    "description": "The name of the environment variable"
                },
                "mount": {
                    "$ref": "#/$defs/SecretMount",
                    "description": "Defines the mount type for the result of the command into the build."
                }
            },
            "required": [
                "type",
                "name",
                "mount"
            ]
        },
        "SecretFile": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "const": "file",
                    "description": "A secret pulled from a file."
                },
                "source": {
                    "type": "string",
                    "description": "The source file containing the secret.\n\nNOTE: Relative paths are relative to the root of the repository."
                },
                "mount": {
                    "$ref": "#/$defs/SecretMount",
                    "description": "Defines the mount type for the result of the command into the build."
                }
            },
            "required": [
                "type",
                "source",
                "mount"
            ]
        },
        "SecretExec": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "const": "exec",
                    "description": "A secret pulled from the stdout of a command."
                },
                "command": {
                    "type": "string",
                    "description": "The command that will be executed."
                },
                "args": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "description": "Arguments for the command being executed."
                },
                "mount": {
                    "$ref": "#/$defs/SecretMount",
                    "description": "Defines the mount type for the result of the command into the build."
                }
            },
            "required": [
                "type",
                "command",
                "mount"
            ]
        },
        "SecretSsh": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "const": "ssh",
                    "description": "Mount the SSH socket to use the hosts SSH socket."
                }
            },
            "required": [
                "type"
            ]
        },
        "SecretMount": {
            "anyOf": [
                {
                    "$ref": "#/$defs/SecretMountEnv"
                },
                {
                    "$ref": "#/$defs/SecretMountFile"
                }
            ]
        },
        "SecretMountEnv": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "const": "env",
                    "description": "A secret pulled from a file on the host system."
                },
                "name": {
                    "type": "string",
                    "description": "The environment variable where the secret will be set."
                }
            },
            "required": [
                "type",
                "name"
            ]
        },
        "SecretMountFile": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "const": "file",
                    "description": "A secret pulled from a file on the host system."
                },
                "destination": {
                    "type": "string",
                    "description": "The destination path in the build to mount the secret."
                }
            },
            "required": [
                "type",
                "destination"
            ]
        }
    }
}