/nimdeps

Nim library to bundle dependency files into executable

Primary LanguageNimMIT LicenseMIT

Nimdeps is a Nim package to bundle dependency files into the generated executable.

It is very common to have external dependency files such as data files, graphics and other payloads as part of an application. Nimdeps makes it easy to carry all this payload within the application binary instead of having to build a separate installer.

All dependencies get packaged into the application binary at compile time. All references to dependencies need to be relative to the application project directory at compile time. At runtime, all files are checked for existence and extracted if not already present or changed. Dependencies get extracted relative to the application location at runtime.

Installation

Nimdeps can be installed via Nimble:

> nimble install nimdeps

This will download and install nimdeps in the standard Nimble package location, typically ~/.nimble. Once installed, it can be imported into any Nim program.

Usage

Module documentation can be found here.

import nimdeps

const FILES = @["data.dat", "icon.png"]
setupDepFiles(FILES)

setupDepDir("depDir1")

setupDeps(@["data2.dat", "depDir2"])

NOTE: Nimdeps should be invoked prior to loading any of the dependencies so that they are extracted prior to usage. At this time, DLL files are not supported if they are loaded using the {.dynlib.} pragma since Nim loads such libraries prior to nimdeps running. Likewise if they are linked with -l since the OS checks for them at load time. This can be avoided by manually loading the DLL using the dynlib module or lazily loaded using the lazylib package.

Feedback

Nimdeps is a work in progress and any feedback or suggestions are welcome. It is hosted on GitHub with an MIT license so issues, forks and PRs are most appreciated.