Giter Site home page Giter Site logo

happ-template's Introduction

hApp Example

This simple Rust hApp demonstrates how to use Nix derivations to:

  • Build the hApp DNA locally, or via use of the hApp's Nix expression in another project
  • Develop using local development branches of dependencies such as holochain-rust
  • Integrate with Hydra, CircleCI and other CI services

Nix Configuration

To build a hApp using Nix and the https://github.com/Holo-Host/holo-nixpkgs tools, copy the default.nix, pkgs.nix and shell.nix files here, with your hApp's name substituted for the happ-example name in the files. This enables you to build your hApp's DNA using tooling supplied by holo-nixpkgs.

Build release DNA

Run nix-build -A happ-example.

Develop against a local holochain-rust version

Run nix-shell -I holochain-rust=../holochain-rust, where ../holochain-rust is a path to holochain-rust checkout. Then, develop as usual.

Develop against built-in holochain-rust version

See previous section, run nix-shell without arguments.

Testing

Holochain hApps typically use both Rust unit tests, and Javascript-based "Scenario" tests written using the Try-o-rama npm module, and sim2h network/DHT simulation.

Binary Caches

Both testing and production builds requires access to significant prerequises. Instead of rebuilding these, we can access the cached binary assets available from both nixos.org and holo.host.

To accelerate building of the holochain-rust and other dependencies, configure the appropriate binary caches.

Configure nix.conf

To take leverage of Holo and NixOS binary caches, set substituters and trusted-public-keys in nix.conf to the following values:

substituters = https://cache.holo.host/ https://cache.nixos.org/
trusted-public-keys = cache.holo.host-1:lNXIXtJgS9Iuw4Cu6X0HINLu9sTfcjEntnrgwMQIMcE= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=

For single-user installs (nix-shell -p nix-info --run nix-info prints multi-user: no), config file is in ~/.config/nix/nix.conf.

Otherwise, for multi-user installs, config file is in /etc/nix/nix.conf and changing it requires root access.

Scenario Testing

Create the Holochain scenario tests in the test/ directory, and use hc test to execute them. If using sim2h, ensure that it is available on the expected port, eg. sim2h_server -p 9000.

These can be manually executed using make test (remember to enter nix-shell first, or hit make nix-test to use nix-shell automatically). The hc test utility will be used to execute the tests.

CircleCI

.circleci/config.yml is used to execute hc test. The cache.holo.host and cache.nixos.org binary caches are used to accelerate the process of obtaining the build artifacts.

Holochain hApps typically use Javascript-based "Scenario" tests written using Try-o-rama.

Hydra

If the test/ directory exists, it is assumed to contain a package-lock.json specifying all of the required NodeJS npm artifacts, and an index.js containing the Scenario tests to run. If found, the underlying holo-nixpkgs Nix configuration will direct the Hydra server to execute the tests.

happ-template's People

Contributors

lukateras avatar pjkundert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.