ic-nix
ic-nix copied to clipboard
Build Internet Computer projects with Nix
Build Internet Computer Projects with Nix
Unofficial build of common binaries used by developers of the Internet Computer blockchain.
- Directly built from source.
- Cross-platform (Linux and Mac OS X, both
x86_64
andaarch64
). - Mostly statically linked with no extra runtime dependency other than libc.
- Weekly release of latest versions at build time.
- Optionally, a standalone SDK environment for nix-shell.
Usage
Depending on your objective, you can do any the following:
- To build a project, run
nix-build -A <project>
. - To enter a development environment for a project, run
nix-shell -A <project>.shell
. - To download the latest pre-built binaries, go to release page.
- To start canister SDK development with latest build, run:
nix-shell https://github.com/ninegua/ic-nix/releases/latest/download/dfx-env.tar.gz
All you need is a working nix installation on your computer.
For aarch64 (Apple M1) architecture, you have a couple choices:
- Compile everything from source by passing extra argument
--arg force true
. - Use
x86_64
binaries by passing extra argument--argstr system x86_64
. - Use pre-built
aarch64
binaries by getting it from the 20231003 release. These were built offline and manually uploaded.
Before you compile from source, you may also want to setup the binary cache (courtesy of cachix) by nix-shell -p cachix --run 'cachix use ninegua'
to avoid unnecessary compilation.
VSCode/direnv
Assuming you're developing on ic
.
- Make sure you have
direnv
installed. - Clone this repo next to
ic
. - Under
ic/rs
: runecho "use nix ../../ic-nix/default.nix -A ic.shell" > .envrc
. - In the same directory, run
direnv allow .
If using VSCode, you should also install the direnv vscode extension, to make sure that rust-analyzer will be using the same versions of Rust as your shell.
WARNING
Releases are built against the latest main branches of each project on a weekly update schedule. They may not always work. Please understand the risks before proceed.
Supported projects
Supported platforms:
- [x] Linux x86-64
- [x] Linux aarch-64 (*)
- [x] OS X x86-64 (*)
- [x] OS X aarch-64 (*)
(*) Build succeeds, but running some of the tests could fail.
Supported nixpkgs:
- [x] 22.11
- [x] 23.05
- [ ] unstable
Feature:
- [x] Build native binaries with nix-build with glibc.
- [x] Dynamic binaries with minimal dependencies: glibc on Linux, system libs on OS X.
- [x] Build Wasm binaries with nix-build.
- [x] Develop with nix-shell.
- [x] Build release binaries on Github.
- [ ] Build and run all tests.
Note that this effort requires no nix support of a project unless it already has.