o
odinpkg.dev
packages / library / opm

opm

v0.1.3library

Odin Package Manager

No license · updated 6 months ago

opm - Odin Package Manager

⚠️ Warning: This tool is AI-generated. Bugs are common. Please file an issue if you find one.

A CLI tool for managing Odin projects, packages, and compiler versions.

Features

  • Version Management - Install, switch, and manage multiple Odin compiler versions
  • Package Management - Add dependencies from GitHub or local paths
  • Project Management - Initialize, build, run, and test Odin projects
  • Fast - Built with Bun for maximum performance

Installation

Prerequisites

  • Bun installed on your system
  • Git (for cloning packages)

Install from source

git clone https://github.com/biswas08433/opm.git
cd opm
bun install
bun link

Build standalone binary

bun run build
# Creates ./opm executable
sudo mv opm /usr/local/bin/

Usage

Version Management

Manage Odin compiler versions:

# List available versions
opm versions

# Install a specific version
opm install dev-2024-01
opm install latest

# Switch to an installed version
opm use dev-2024-01

# Show current version
opm current

# Uninstall a version
opm uninstall dev-2024-01

After installing, add opm's current version to your PATH:

export PATH="$HOME/.opm/current:$PATH"

Project Management

Create and manage Odin projects:

# Initialize a new project
opm init my-project
cd my-project

# Or initialize in current directory
opm init

# Show project info
opm info

# Build the project
opm build

# Run the project
opm run

# Run tests
opm test

# Check for errors
opm check

# Clean build artifacts
opm clean

Package Management

Manage project dependencies:

# Add a dependency
opm add odin-lang/odin-libs
opm add user/repo@v1.0.0
opm add user/repo#branch

# Add a dev dependency
opm add -D some-dev-tool/repo

# Remove a package
opm remove package-name

# Update packages
opm update           # Update all
opm update pkg-name  # Update specific

# Install all dependencies
opm install

# Install with frozen lockfile (CI/reproducible builds)
opm install --frozen

# List installed packages
opm list

# Search for packages
opm search raylib

Lockfile (opm.lock)

opm uses a lockfile (opm.lock) to ensure deterministic, reproducible builds:

  • Automatic: When you add or install a package, opm records the exact commit hash
  • Reproducible: Running opm install will always install the same versions
  • Frozen mode: Use opm install --frozen in CI to fail if lockfile is missing or outdated
# Normal install - creates/updates lockfile
opm install

# Frozen install - requires exact lockfile match (for CI)
opm install --frozen

Tip: Commit opm.lock to your repository for reproducible builds across machines.

Package Specifiers

Format Description
user/repo GitHub repository (shorthand)
user/repo@v1.0.0 Specific tag
user/repo#branch Specific branch
github:user/repo Explicit GitHub
git:https://... Any Git URL
path:/local/path Local path (symlinked)

Project Configuration

Projects use an opm.json file:

{
  "name": "my-project",
  "version": "0.1.0",
  "description": "My Odin project",
  "author": "Your Name",
  "license": "MIT",
  "odinVersion": "dev-2024-01",
  "dependencies": {
    "raylib": "odin-lang/raylib-odin"
  },
  "devDependencies": {},
  "collections": {
    "raylib": "odin_packages/raylib"
  },
  "scripts": {
    "custom": "echo 'custom script'"
  },
  "build": {
    "src": "src",
    "out": "bin",
    "flags": ["-debug"]
  }
}

Directory Structure

opm stores its data in ~/.opm/:

~/.opm/
├── versions/           # Installed Odin versions
│   ├── dev-2024-01/
│   └── dev-2024-02/
├── current -> versions/dev-2024-01  # Symlink to active version
├── cache/              # Download cache
└── config.json         # Global configuration

Projects have this structure:

my-project/
├── src/
│   └── main.odin
├── tests/
├── bin/
├── odin_packages/      # Installed dependencies
├── opm.json            # Project configuration
├── opm.lock            # Lockfile for reproducible builds
└── .gitignore

Development

# Run in development mode
bun run dev

# Run tests
bun test

# Build binary
bun run build

License

MIT