Skip to content

Configuration

Structyl uses a JSON configuration file to define your project settings, targets, and build options.

Configuration File

Every Structyl project needs a .structyl/config.json file at the project root. This file:

  • Marks the project root directory
  • Defines project metadata
  • Configures build targets
  • Specifies test and documentation settings

Basic Structure

Here's a minimal configuration:

json
{
  "project": {
    "name": "my-library"
  }
}

And a typical configuration with targets:

json
{
  "project": {
    "name": "my-library",
    "description": "A multi-language library"
  },
  "version": {
    "source": "VERSION"
  },
  "targets": {
    "rs": {
      "type": "language",
      "title": "Rust",
      "toolchain": "cargo"
    },
    "py": {
      "type": "language",
      "title": "Python",
      "toolchain": "uv"
    }
  }
}

Configuration Sections

project

Project metadata used in documentation and package generation.

json
{
  "project": {
    "name": "my-library",
    "description": "A multi-language library",
    "homepage": "https://my-library.dev",
    "repository": "https://github.com/user/my-library",
    "license": "MIT"
  }
}
FieldRequiredDescription
nameYesProject name (lowercase, hyphens allowed)
descriptionNoShort description
homepageNoProject website URL
repositoryNoSource repository URL
licenseNoSPDX license identifier

version

Configure where Structyl reads the project version.

json
{
  "version": {
    "source": "VERSION"
  }
}

See Version Management for details on version propagation.

targets

Define build targets for your project.

json
{
  "targets": {
    "rs": {
      "type": "language",
      "title": "Rust",
      "toolchain": "cargo"
    },
    "img": {
      "type": "auxiliary",
      "title": "Image Generation",
      "commands": {
        "build": "python scripts/generate.py"
      }
    }
  }
}

See Targets for detailed target configuration.

tests

Configure the reference test system.

json
{
  "tests": {
    "directory": "tests",
    "pattern": "**/*.json",
    "comparison": {
      "float_tolerance": 1e-9,
      "tolerance_mode": "relative"
    }
  }
}

See Testing for details on cross-language testing.

docker

Enable Docker-based builds.

json
{
  "docker": {
    "compose_file": "docker-compose.yml",
    "services": {
      "rs": {"base_image": "rust:1.75"},
      "py": {"base_image": "python:3.12-slim"}
    }
  }
}

See Docker for container configuration.

Target Configuration

Each target supports these options:

FieldTypeDefaultDescription
typestringRequired"language" or "auxiliary"
titlestringRequiredDisplay name
toolchainstringAuto-detectToolchain preset
directorystringTarget keyDirectory path
cwdstringdirectoryWorking directory
commandsobjectFrom toolchainCommand overrides
varsobject{}Custom variables
envobject{}Environment variables
depends_onarray[]Dependency targets

Command Definitions

Override toolchain commands or define custom ones:

json
{
  "targets": {
    "cs": {
      "toolchain": "dotnet",
      "commands": {
        "test": "dotnet run --project MyLib.Tests",
        "demo": "dotnet run --project MyLib.Demo"
      }
    }
  }
}

Commands can be:

  • Strings: Shell commands
  • Arrays: Sequential command execution
  • Objects: Commands with custom cwd/env
json
{
  "commands": {
    "build": "cargo build",
    "check": ["lint", "format-check"],
    "test": {
      "run": "pytest",
      "cwd": "tests",
      "env": {"PYTHONPATH": "."}
    }
  }
}

Variables

Use variables in commands for flexibility:

json
{
  "targets": {
    "cs": {
      "vars": {
        "test_project": "MyLib.Tests"
      },
      "commands": {
        "test": "dotnet run --project ${test_project}"
      }
    }
  }
}

Built-in variables:

VariableDescription
${target}Target slug (e.g., cs, py)
${target_dir}Target directory path
${root}Project root directory
${version}Project version

Schema Validation

Enable IDE autocomplete by adding a schema reference:

json
{
  "$schema": "https://structyl.dev/schemas/structyl.schema.json",
  "project": {
    "name": "my-library"
  }
}

Full Example

json
{
  "project": {
    "name": "my-library",
    "description": "Multi-language library",
    "license": "MIT"
  },
  "version": {
    "source": "VERSION"
  },
  "targets": {
    "rs": {
      "type": "language",
      "title": "Rust",
      "toolchain": "cargo"
    },
    "py": {
      "type": "language",
      "title": "Python",
      "toolchain": "uv",
      "commands": {
        "demo": "uv run python examples/demo.py"
      }
    },
    "go": {
      "type": "language",
      "title": "Go",
      "toolchain": "go"
    }
  },
  "tests": {
    "directory": "tests",
    "comparison": {
      "float_tolerance": 1e-9
    }
  }
}

Next Steps

  • Targets - Learn about target types and dependencies
  • Commands - Understand the command system
  • Toolchains - See all supported toolchains

Released under the MIT License.