Skip to content

Project Configuration

Nic projects are configured using a nic.toml manifest file in the project root.

Basic Structure

toml
[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:

toml
[project]
name = "myproject"        # Required: project name
version = "0.1.0"         # Required: semantic version
authors = ["Name <email>"] # Optional: list of authors
description = "..."        # Optional: project description

Fields

FieldTypeRequiredDescription
namestringYesProject name (used as binary name)
versionstringYesSemantic version string
authorsstring[]NoList of author names/emails
descriptionstringNoShort project description

[paths] Section

Configure source and library paths:

toml
[paths]
src = "src/"           # Required: source directory
std = "/custom/std"    # Optional: override std library path

Fields

FieldTypeDefaultDescription
srcstring"src/"Source directory containing Nic files
stdstringautoOverride 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:

toml
[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:

toml
[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 flags

Fields

FieldTypeDefaultDescription
ccstring"cc"C compiler executable
cflagsstring[][]C compiler flags
librariesstring[][]Libraries to link (without -l prefix)
library_pathsstring[][]Library search paths (without -L prefix)
include_pathsstring[][]Include paths (without -I prefix)
sourcesstring[][]C source files to compile and link
headersstring[][]Headers for automatic binding generation
ldflagsstring[][]Additional linker flags

Header Auto-Binding

Headers listed in headers are automatically processed by bindgen during build:

toml
[ffi]
headers = ["vendor/sqlite3.h"]
include_paths = ["vendor/"]

Generated bindings are placed in .nicc-build/ffi/ and automatically available for import:

nic
import "sqlite3.h";  // Uses generated bindings

Compiling C Sources

C files listed in sources are compiled to object files and linked with your program:

toml
[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:

toml
[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:

toml
[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 files

Module Resolution

Imports are resolved relative to the src directory:

nic
// In src/main.nic
import lib;              // src/lib.nic
import utils.helpers;    // src/utils/helpers.nic
import std.io;           // Standard library

Build Artifacts

The .nicc-build/ directory contains:

  • ffi/*.nic - Generated C bindings
  • *.o - Compiled C object files

Add to .gitignore:

.nicc-build/

See Also

Released under the MIT License.