(sigil package)
(sigil package) - Package Definition Library
This library provides struct types for defining Sigil packages. A package.sgl file uses these structs to declare package metadata, build configurations, tasks, and dependencies.
Example package.sgl:
(package name: "my-app" version: "0.1.0" entry: '((my-app main) main) configs: (list (config name: 'dev debug?: #t) (config name: 'release optimize: 2)) dependencies: (list (from-git url: "https://example.com/lib" tag: "v1.0")))
Exports
packageprocedureThe central struct defining a Sigil package.
(package
name: "my-app"
version: "1.0.0"
description: "My application"
entry: '((my-app main) main)
dependencies: (list
(from-git url: "https://github.com/example/lib.git" tag: "v1.0")))package?procedureTest if a value is a package struct.
package-nameprocedurePackage name as a string. Used for identification and as default bundle name.
package-versionprocedureSemantic version string. When #f, inherits version from workspace if loaded as a workspace package, or defaults to "0.0.0" when loaded standalone.
package-descriptionprocedureShort description of the package.
package-urlprocedureProject URL (repository, homepage, etc.) or #f.
package-licenseprocedureLicense identifier string (e.g., "MIT", "Apache-2.0") or #f.
package-authorsprocedureList of author strings in "Name <email>" format.
package-entryprocedureEntry point as '((library-name ...) proc-name) or #f for library-only packages.
package-bundle-nameprocedureOutput executable name for bundles. Defaults to package name if #f.
package-runtimeprocedureRuntime composition strategy for bundled executables.
'reuse(default): Reuse the CLI runtime if the app's native dependencies are a subset of what CLI provides. Fast bundling, but includes all CLI native packages even if unused.'custom: Build a runtime with exactly the native packages the app needs. Slower build, but precise control over binary contents. Use this for smaller binaries (omit unused packages) or larger ones (add packages not in CLI like sigil-studio).
Can be overridden with sigil build --runtime=custom.
package-configsprocedureBuild configurations as <config> records.
package-default-configprocedureSymbol naming the default config to use. Common values: 'dev, 'release.
package-librariesprocedureLibrary targets as <library> records.
package-executablesprocedureExecutable targets as <executable> records.
package-tasksprocedureBuild tasks as <task> records.
package-dependenciesprocedureRuntime dependencies as <from-git>, <from-path>, or <from-workspace> records.
package-dev-dependenciesprocedureDevelopment-only dependencies (not bundled in release builds).
package-hooksprocedureBuild lifecycle hooks as a <hooks> record, or #f for none.
package-providesprocedureCapabilities this package provides. A keyword-tagged list, e.g., (list mcp-tools: '(sigil web mcp tools)).
%config--typevariableCapabilities this package provides. A keyword-tagged list, e.g., (list mcp-tools: '(sigil web mcp tools)).
configprocedureBuild configuration defining compiler flags, toolchain, and output settings.
(config
name: 'release
optimize: 2
static?: #t
c-flags: '("-Wall" "-Werror"))config?procedureTest if a value is a config struct.
config-nameprocedureConfiguration name as a symbol. Common values: 'dev, 'release, 'static:release.
config-output-dirprocedureBase output directory. Config name is appended (e.g., "build/release").
config-toolchainprocedureToolchain selector. Values: 'native, 'emscripten, 'musl, 'zig, or custom symbol.
config-targetprocedureCross-compilation target triple for zig toolchain. Examples: "aarch64-linux-musl", "x86_64-windows-gnu", "x86_64-freebsd". Only used when toolchain is 'zig. If #f, builds for native target.
config-c-compilerprocedureOverride C compiler command. Examples: "musl-gcc", "emcc", "clang".
config-arprocedureOverride archiver command for static libraries.
config-c-flagsprocedureAdditional C compiler flags as a list of strings.
config-link-flagsprocedureAdditional linker flags as a list of strings.
config-definesprocedurePreprocessor defines as a list of strings or (name . value) pairs.
config-featuresprocedureFeature flags for cond-expand in Sigil source files.
config-static?procedureIf #t, build a fully static executable (requires musl or similar).
config-debug?procedureIf #t, include debug symbols in output.
config-optimizeprocedureOptimization level from 0 (none) to 3 (aggressive).
config-bundle?procedureIf #t, create a bundled executable with embedded modules.
config-deploy-dirprocedureSubdirectory for deployable assets (e.g., "www" for web builds).
%task--typevariableSubdirectory for deployable assets (e.g., "www" for web builds).
taskprocedureNamed build workflow that composes action steps with dependencies.
(task
name: 'test
description: "Run all tests"
depends: '(build)
steps: (list (shell "make test")))task?procedureTest if a value is a task struct.
task-nameprocedureTask name as a symbol.
task-descriptionprocedureHuman-readable description of what this task does.
task-dependsprocedureList of task name symbols that must run before this task.
task-configsprocedureList of config names this task applies to, or #f for all configs.
task-stepsprocedureAction steps to execute in sequence. Each step is an action record.
%library--typevariableAction steps to execute in sequence. Each step is an action record.
libraryprocedureA library target producing a static archive from C and Sigil sources.
(library
name: 'sigil-crypto
c-sources: '("native/crypto.c" "vendor/mbedtls/library/*.c")
c-include-dirs: '("vendor/mbedtls/include")
native-init: "sigil__init_sigil_crypto_module")library?procedureTest if a value is a library struct.
library-nameprocedureLibrary name as a symbol.
library-c-sourcesprocedureC source files as a list of paths or glob patterns.
library-c-include-dirsprocedureC include directories as a list of paths.
library-c-flagsprocedureAdditional C compiler flags for this library. Use (cond-expand ...) for platform-dependent flags. Example: '("-DFOO=1" "-Wno-deprecated") for defines/warnings.
library-sigil-sourcesprocedureSigil source files as a list of paths or glob patterns.
library-outputprocedureOutput filename. Defaults to lib<name>.a if #f.
library-native-initprocedureNative init function name (C symbol) called at VM startup. Used for packages with native code that register Scheme primitives.
library-link-flagsprocedurePlatform-specific linker flags for this library. Use (cond-expand ...) for platform-dependent flags. Example: '("-lX11" "-lGL") for graphics libraries.
%executable--typevariablePlatform-specific linker flags for this library. Use (cond-expand ...) for platform-dependent flags. Example: '("-lX11" "-lGL") for graphics libraries.
executableprocedureAn executable target that links libraries into a runnable program.
(executable
name: 'my-app
entry: '((my-app main) run)
libraries: '(core utils))executable?procedureTest if a value is a executable struct.
executable-nameprocedureExecutable name as a symbol.
executable-entryprocedureEntry point as '((library-name ...) proc-name), or #f for pure C executables.
executable-librariesprocedureList of library name symbols to link.
%hooks--typevariableList of library name symbols to link.
hooksprocedureBuild lifecycle hooks for customizing build and test phases.
(hooks
before-build: (lambda (config) (display "Building...\n"))
after-build: (lambda (config output) (display "Done!\n")))hooks?procedureTest if a value is a hooks struct.
hooks-before-buildprocedureCalled before build starts. Receives (config).
hooks-after-buildprocedureCalled after build completes. Receives (config output-path).
hooks-before-testprocedureCalled before tests run. Receives (config).
hooks-after-testprocedureCalled after tests complete. Receives (config results).
%workspace--typevariableCalled after tests complete. Receives (config results).
workspaceprocedureA workspace containing multiple packages with shared configuration and tasks.
(workspace
name: "my-project"
packages: (list "packages/pkg1" "packages/pkg2")
configs: (list
(config name: 'dev debug?: #t)
(config name: 'release optimize: 2)))workspace?procedureTest if a value is a workspace struct.
workspace-nameprocedureWorkspace name as a string.
workspace-versionprocedureSemantic version string.
workspace-descriptionprocedureShort description of the workspace.
workspace-urlprocedureProject URL or #f.
workspace-licenseprocedureLicense identifier or #f.
workspace-authorsprocedureList of author strings in "Name <email>" format.
workspace-packagesprocedurePackage directories as paths or glob patterns.
workspace-configsprocedureShared build configurations as <config> records.
workspace-default-configprocedureDefault config name symbol.
workspace-tasksprocedureWorkspace-level tasks as <task> records.
%from-git--typevariableWorkspace-level tasks as <task> records.
from-gitprocedureA git dependency referencing a remote repository. Supports forge shorthand URLs: codeberg:user/repo, github:user/repo.
(from-git
url: "codeberg:sigil/sigil"
subpath: "packages/sigil-json"
tag: "v1.0.0")from-git?procedureTest if a value is a from-git struct.
from-git-urlprocedureRepository URL (HTTPS, SSH, or forge shorthand).
from-git-nameprocedureOverride package name inferred from URL. If #f, uses repo name.
from-git-subpathprocedurePath within repo to package directory (for monorepos).
from-git-packageprocedurePackage name to find in workspace (alternative to subpath). When set, the resolver clones the repo, reads its workspace definition, and locates the package by name. Mutually exclusive with subpath.
from-git-versionprocedureSemver version range constraint. When set, the resolver fetches available tags from the remote and selects the highest matching version. Supports Cargo-style ranges: "^0.9.0" → >=0.9.0, <0.10.0 "~0.9.0" → >=0.9.0, <0.9.1 "*" → any version (latest tag) When #f, uses tag/branch/commit or HEAD.
from-git-tagprocedureCheckout a specific git tag.
from-git-branchprocedureTrack a branch (pulls latest on update).
from-git-commitprocedurePin to an exact commit hash.
%from-path--typevariablePin to an exact commit hash.
from-pathprocedureA local path dependency for development or monorepo setups.
If package is specified, dir points to a workspace root and the named package is resolved within it. If omitted, dir is the package directory itself.
(from-path dir: "../my-local-lib")
(from-path dir: "../workspace" package: "specific-pkg")from-path?procedureTest if a value is a from-path struct.
from-path-dirprocedureFilesystem path to the package directory or workspace root.
from-path-packageprocedurePackage name to find in workspace (if dir is a workspace).
from-path-nameprocedureOverride inferred package name. If #f, uses directory name.
%from-workspace--typevariableOverride inferred package name. If #f, uses directory name.
from-workspaceprocedureA workspace dependency referencing a sibling package. Used by monorepo packages to declare dependencies on other packages in the same repository. When fetched externally, resolves to the same worktree/ref as the parent package.
(from-workspace name: "sigil-stdlib")from-workspace?procedureTest if a value is a from-workspace struct.
from-workspace-nameprocedurePackage name within the workspace.
alist-getprocedureHelper to get value from alist
package-provides-refprocedureLook up a value from a package's provides list by keyword.
Returns the value following the keyword, or #f if not found.
(package-provides-ref pkg mcp-tools:)
;; => (sigil web mcp tools)find-package-fileprocedureFind package.sgl in current directory or ancestors
load-packageprocedureLoad and evaluate a package.sgl file Returns the <package> record
Automatically imports (sigil package) and (sigil build) so that package files don't need explicit import statements.
Note: All expressions are wrapped in a single (begin ...) form and evaluated together.
load-package-or-workspaceprocedureLoad and evaluate a package.sgl file, returning either package or workspace Returns the <package> or <workspace> record
package->workspaceprocedureWrap a standalone package in a workspace This normalizes the API so all code can work with workspaces
read-all-exprsprocedureRead all expressions from a port
package-output-dirprocedureGet output directory for a config
resolve-configprocedureResolve a config by name from a package
workspace-resolve-configprocedureResolve a config by name from a workspace
workspace-package-pathsprocedureGet absolute paths to all packages in a workspace workspace-dir: directory containing the workspace package.sgl
workspace-load-packagesprocedureLoad all packages from a workspace Returns alist of (package-name . package) pairs Packages without a version inherit the workspace version.