Skip to content

Configuration Schema

This page documents the CUE schema definitions used in cuenv configurations. Import these from github.com/cuenv/cuenv/schema in your env.cue files.

The root configuration type that validates your entire env.cue file.

import "github.com/cuenv/cuenv/schema"
schema.#Cuenv
// Your configuration here
env: {...}
tasks: {...}

Fields:

FieldTypeRequiredDescription
config#ConfigNoGlobal configuration options
env#EnvNoEnvironment variable definitions
hooks#HooksNoShell hooks for onEnter/onExit
tasks{[string]: #Tasks}YesTask definitions
workspaces#WorkspacesNoWorkspace configuration

Global configuration options.

config: {
outputFormat: "tui" // or "spinner", "simple", "tree", "json"
}

Fields:

FieldTypeDefaultDescription
outputFormatstring-Task output format

Output Formats:

FormatDescription
tuiInteractive terminal UI
spinnerSimple spinner with status
simplePlain text output
treeTree-structured output
jsonJSON output for scripting

Environment variable definitions with optional environment-specific overrides.

env: {
NODE_ENV: "development"
PORT: 3000
DEBUG: true
// Environment-specific overrides
environment: {
production: {
NODE_ENV: "production"
DEBUG: false
}
}
}

A single environment variable value. Can be:

env: {
// Simple string
NAME: "value"
// Number (converted to string when exported)
PORT: 3000
// Boolean (converted to string when exported)
DEBUG: true
// Secret reference
API_KEY: schema.#Secret & {
command: "op"
args: ["read", "op://vault/item/field"]
}
// Value with access policies
DB_PASSWORD: {
value: schema.#Secret & {...}
policies: [{
allowTasks: ["migrate"]
}]
}
}

Environment variable naming constraint: must match ^[A-Z][A-Z0-9_]*$ (uppercase with underscores).

env: {
VALID_NAME: "ok" // Valid
valid_name: "error" // Invalid - must be uppercase
123_NAME: "error" // Invalid - must start with letter
}

A task can be a single command, a list (sequential), or a group (parallel/nested).

tasks: {
// Single task
build: {
command: "cargo"
args: ["build"]
}
// Sequential list
deploy: [
{command: "build"},
{command: "push"},
]
// Nested group
test: {
unit: {command: "cargo", args: ["test", "--lib"]}
e2e: {command: "cargo", args: ["test", "--test", "e2e"]}
}
}

A single task definition.

tasks: {
build: {
// Required
command: "cargo"
// Optional
args: ["build", "--release"]
shell: schema.#Bash
env: {
RUST_LOG: "debug"
}
dependsOn: ["lint", "test"]
inputs: ["src/**/*.rs", "Cargo.toml"]
outputs: ["target/release/myapp"]
description: "Build the application"
workspaces: ["packages/core"]
}
}

Fields:

FieldTypeRequiredDescription
commandstringYesCommand to execute
args[...string]NoCommand arguments
shell#ShellNoShell to use for execution
env{[string]: #EnvironmentVariable}NoTask-specific environment
dependsOn[...string]NoTask dependencies
inputs[...string]NoInput file patterns for caching
outputs[...string]NoOutput file patterns for caching
descriptionstringNoHuman-readable description
workspaces[...string]NoWorkspaces to enable
externalInputs[...#ExternalInput]NoCross-project dependencies

Task groups determine execution mode by structure:

// Array = Sequential execution
sequential: [
{command: "step1"},
{command: "step2"},
{command: "step3"},
]
// Object = Parallel/nested execution
parallel: {
task1: {command: "cmd1"}
task2: {command: "cmd2"}
nested: {
subtask: {command: "cmd3"}
}
}

Cross-project task dependencies (monorepo feature).

tasks: {
build: {
command: "build"
externalInputs: [{
project: "../shared-lib"
task: "build"
map: [{
from: "dist/lib.js"
to: "vendor/lib.js"
}]
}]
}
}

Fields:

FieldTypeDescription
projectstringPath to external project
taskstringTask name in external project
map[...#Mapping]Output mappings

Shell hooks executed on directory entry/exit.

hooks: {
onEnter: {
setup: {
command: "echo"
args: ["Entering project"]
}
}
onExit: {
cleanup: {
command: "echo"
args: ["Leaving project"]
}
}
}

A single hook definition.

hooks: {
onEnter: {
nix: schema.#NixFlake
custom: {
order: 50
propagate: true
command: "setup.sh"
args: ["--dev"]
dir: "."
inputs: ["setup.sh"]
source: false
}
}
}

Fields:

FieldTypeDefaultDescription
commandstringrequiredCommand to execute
args[...string][]Command arguments
orderint100Execution order (lower = earlier)
propagateboolfalseExport variables to children
dirstring”.”Working directory
inputs[...string][]Input files for cache tracking
sourceboolfalseSource output as shell script

Built-in hook for loading Nix flake environments.

hooks: {
onEnter: {
nix: schema.#NixFlake
}
}

Definition:

#NixFlake: #ExecHook & {
order: 10
propagate: true
command: "nix"
args: ["print-dev-env"]
source: true
inputs: ["flake.nix", "flake.lock"]
}

Shell configuration for task execution.

shell: {
command: "bash"
flag: "-c"
}
TypeCommandFlag
#Bashbash-c
#Zshzsh-c
#Fishfish-c
#Shsh-c
#Cmdcmd/C
#PowerShellpowershell-Command

Usage:

tasks: {
build: {
shell: schema.#Bash
command: "echo"
args: ["Building..."]
}
}

Base secret type with exec-based resolution.

env: {
MY_SECRET: schema.#Secret & {
resolver: "exec"
command: "echo"
args: ["secret-value"]
}
}

Fields:

FieldTypeDescription
resolver"exec"Always “exec”
commandstringCommand to retrieve secret
args[...string]Command arguments

1Password secret reference.

env: {
API_KEY: schema.#OnePasswordRef & {
ref: "op://vault/item/field"
}
}

Fields:

FieldTypeDescription
refstring1Password reference URI

Google Cloud Secret Manager reference.

env: {
DB_PASSWORD: schema.#GcpSecret & {
project: "my-project"
secret: "db-password"
version: "latest" // default
}
}

Fields:

FieldTypeDefaultDescription
projectstringrequiredGCP project ID
secretstringrequiredSecret name
versionstring”latest”Secret version

Access control policy for environment variables.

env: {
SENSITIVE_KEY: {
value: schema.#Secret & {...}
policies: [{
allowTasks: ["deploy", "release"]
allowExec: ["kubectl", "helm"]
}]
}
}

Fields:

FieldTypeDescription
allowTasks[...string]Tasks that can access this variable
allowExec[...string]Exec commands that can access

Workspace configuration for monorepos.

workspaces: {
"packages/core": {
enabled: true
package_manager: "pnpm"
root: "packages/core"
}
}

Fields:

FieldTypeDefaultDescription
enabledbooltrueEnable this workspace
package_managerstring-Package manager type
rootstring-Workspace root directory

Package Managers:

  • npm
  • pnpm
  • yarn
  • yarn-classic
  • bun
  • cargo