Project Configuration
Nic projects are configured using a nic.toml manifest file in the project root.
Basic Structure
[project]
name = "myproject"
version = "0.1.0"
authors = ["Your Name"]
description = "A sample project"
[paths]
src = "src/"
[prelude]
enabled = true
[ffi]
# C interop configuration (optional)
[dependencies]
# Package dependencies (future)[project] Section
Required project metadata:
[project]
name = "myproject" # Required: project name
version = "0.1.0" # Required: semantic version
authors = ["Name <email>"] # Optional: list of authors
description = "..." # Optional: project descriptionFields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Project name (used as binary name) |
version | string | Yes | Semantic version string |
authors | string[] | No | List of author names/emails |
description | string | No | Short project description |
[paths] Section
Configure source and library paths:
[paths]
src = "src/" # Required: source directory
std = "/custom/std" # Optional: override std library pathFields
| Field | Type | Default | Description |
|---|---|---|---|
src | string | "src/" | Source directory containing Nic files |
std | string | auto | Override standard library path |
Entry Point
The build system looks for main.nic in the source directory:
myproject/
├── nic.toml
└── src/
└── main.nic # Entry point (must contain main function)[prelude] Section
Control automatic prelude import:
[prelude]
enabled = true # Auto-import prelude types (default: true)When enabled, these types are automatically available:
Option[T],Result[T, E]String,Vec[T]StringMap[V],IntMap[V]
[ffi] Section
Configure C foreign function interface:
[ffi]
cc = "clang" # C compiler
cflags = ["-O2", "-Wall"] # Compiler flags
libraries = ["sqlite3", "z"] # Libraries to link (-l)
library_paths = ["/opt/homebrew/lib"] # Library search paths (-L)
include_paths = ["/opt/homebrew/include"] # Include paths (-I)
sources = ["vendor/helper.c"] # C sources to compile
headers = ["vendor/helper.h"] # Headers for auto-bindgen
ldflags = ["-fPIC"] # Extra linker flagsFields
| Field | Type | Default | Description |
|---|---|---|---|
cc | string | "cc" | C compiler executable |
cflags | string[] | [] | C compiler flags |
libraries | string[] | [] | Libraries to link (without -l prefix) |
library_paths | string[] | [] | Library search paths (without -L prefix) |
include_paths | string[] | [] | Include paths (without -I prefix) |
sources | string[] | [] | C source files to compile and link |
headers | string[] | [] | Headers for automatic binding generation |
ldflags | string[] | [] | Additional linker flags |
Header Auto-Binding
Headers listed in headers are automatically processed by bindgen during build:
[ffi]
headers = ["vendor/sqlite3.h"]
include_paths = ["vendor/"]Generated bindings are placed in .nicc-build/ffi/ and automatically available for import:
import "sqlite3.h"; // Uses generated bindingsCompiling C Sources
C files listed in sources are compiled to object files and linked with your program:
[ffi]
sources = ["src/native/helper.c"]
cflags = ["-O2"]Object files are placed in .nicc-build/ during build.
[dependencies] Section
Dependencies are planned for future versions:
[dependencies]
# Local path dependency (planned)
mylib = { path = "../mylib" }
# Git dependency (planned)
utils = { git = "https://github.com/user/utils", tag = "v1.0.0" }Complete Example
A project using SQLite3:
[project]
name = "myapp"
version = "0.1.0"
authors = ["Developer <dev@example.com>"]
description = "An application using SQLite"
[paths]
src = "src/"
[prelude]
enabled = true
[ffi]
cc = "clang"
cflags = ["-O2"]
libraries = ["sqlite3"]
library_paths = ["/opt/homebrew/lib"]
include_paths = ["/opt/homebrew/include"]
headers = ["include/sqlite3.h"]Project Layout
Recommended project structure:
myproject/
├── nic.toml # Project manifest
├── src/
│ ├── main.nic # Entry point
│ ├── lib.nic # Library code
│ └── utils/
│ └── helpers.nic # Nested modules
├── vendor/ # Third-party C code
│ ├── helper.h
│ └── helper.c
├── tests/ # Test files
│ └── test_main.nic
└── .nicc-build/ # Build artifacts (gitignore this)
├── ffi/ # Generated bindings
└── *.o # Object filesModule Resolution
Imports are resolved relative to the src directory:
// In src/main.nic
import lib; // src/lib.nic
import utils.helpers; // src/utils/helpers.nic
import std.io; // Standard libraryBuild Artifacts
The .nicc-build/ directory contains:
ffi/*.nic- Generated C bindings*.o- Compiled C object files
Add to .gitignore:
.nicc-build/See Also
- CLI Commands - Build and run commands
- C Bindings (bindgen) - FFI binding generation