Skip to content

Reproducible Build With Nix

yihuang edited this page May 9, 2022 · 10 revisions

It's possible to reproducibly build cronosd binaries locally using nix.

Prerequisite

  • Install nix, follow the instructions here: https://nixos.org/download.html
  • Install cachix and enable cronos binary cache:
    $ nix-env -iA cachix -f https://cachix.org/api/v1/install
    $ cachix use cronos
    

Build Type Matrix

  • network type
    • mainnet (default)
    • testnet
  • db backend
    • rocksdb (default)
    • goleveldb
  • build type
    • normal nix package (default)
    • re-distributable bundle
    • re-distributable tarball, the tarball of the above bundle.

The package name is constructed by joining the above properties with seperator -, omitting the default one, for example:

  • cronosd means mainnet rocksdb nix package.
  • cronosd-tarball means mainnet rocksdb re-distributable tarball.
  • cronosd-testnet-goleveldb-tarball means testnet goleveldb re-distributable tarball.

The nix flake url is like: github:crypto-org-chain/cronos/$TAG_NAME#$PACKAGE_NAME, replace the $TAG_NAME and $PACKAGE_NAME to the one you needed, for example, the full command to build a v0.7.0 rocksdb mainnet re-distributable tarball is:

$ nix build github:crypto-org-chain/cronos/v0.7.0#cronosd-tarball

The result is reside at ./result by default, then you can copy the tarball to other machines with the same OS and arch. The re-distributable bundle/tarball has dynamic libraries included, no extra runtime dependency needed.

Clone this wiki locally