How to create a holochain runtime
A holochain runtime is an end-user application that is able to install and open holochain apps and web-apps. Examples of existing runtimes include the launcher and moss.
Scaffolding
WARNING
p2p Shipyard relies heavily on nix to achieve reproducible environments. Unfortunately, nix does not support Windows. So if you have a Windows OS, you will need to install Windows Subsystem Linux and run all the steps in this guide inside of its environment.
- If you haven't already, install the nix package manager with:
sh <(curl -L https://nixos.org/nix/install) --daemonsh <(curl -L https://nixos.org/nix/install)And follow along its instructions and prompts.
- Add the appropriate nix caches to your environment:
nix run nixpkgs#cachix use holochain-ci
nix run nixpkgs#cachix use darksoil-studio- In the folder where you want to create your new holochain runtime, run this command:
nix run github:darksoil-studio/tauri-plugin-holochain#scaffold-holochain-runtimeAnd follow along its instructions and prompts.
- Take a look into the repository structure that the scaffold command created, specially:
flake.nix: with thetauri-plugin-holochaininput and itsdevShells.package.json: added set up scripts and somedevDependencies.src-tauri: here is where the code for the backend of the tauri app lives. For now it's a simple Tauri app that includes thetauri-plugin-holochain.index.html: mainindex.htmlfile that will be displayed when the app is opened.src: this is where the code for the UI lives.- The scaffolded template contains a very bare bones vanilla JS app. Look in
src/main.tsto see how the frontend for your runtime can connect to theAdminWebsocket.
- The scaffolded template contains a very bare bones vanilla JS app. Look in
That's it! We now have a working skeleton for a holochain runtime.
WARNING
The scaffolded tauri app is missing icons, which are needed for the app to compile. Run through the rest of this guide and the following one ("Getting to know Tauri") to be able to generate the icons for your Tauri app.
Development Environment
The scaffold-holochain-apps has added the necessary nix devShells to your flake.nix file so that you don't need to follow install anything to get the tauri or Android development environment.
NOTE
Nix devShells are packages that describe development environments, with all their dependencies and environment variables, so that the developer does not need to configure manually their setup.
As usual, run this command to enter the development environment:
nix developThis can take a while while it builds all the required dependencies.
Next, run these commands:
npm install
npm run tauri devyarn install
yarn tauri devpnpm install
pnpm tauri devThis will start an instance of the app.
Under the hood, these commands are running tauri CLI commands. As such, we should get to know Tauri a bit better to be comfortable while developing the app. Go to Getting to know Tauri to familiarize yourself with it.