Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Cardano Devnet

Cardano testnet for dApp development and testing locally.
Cardano testnet for dApp development and testing locally using process-compose.

See our [website](https://mlabs-haskell.github.io/cardano-devnet-flake) for documentation.

![demo](./docs/src/img/demo.gif)

WARNING: flake-module devnet was deprecated, if you still depend on it, please use
[v1](https://github.com/mlabs-haskell/cardano-devnet-flake/tree/v1.0.0).
70 changes: 0 additions & 70 deletions docs/src/flake-parts.md

This file was deleted.

87 changes: 79 additions & 8 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,82 @@ Benefits compared to other similar solutions:

## How to use

This repository provides two ways to setup a cardano dev network, either as a
flake-parts module, or a process-compose module. The former is simpler, which
might be just enough for your use case, but I would recommend using the
process-compose module, which allows you to configure a full development
environment, similar to docker-compose.

- [Flake parts module](./flake-parts)
- [Process-compose module](./process-compose)
[Process-compose](https://f1bonacc1.github.io/process-compose/) is a utility to
orchestrate multiple processes, similarly to the way docker-compose does this
with docker containers. Process-compose handles configuring health checks,
dependencies between processes, retries, etc.

[Process-compose-flake](https://community.flake.arts/process-compose-flake)
wraps the above utiliy to integrate it with Nix, using flake-parts.

This process-compose module was built based on
[services-flake](https://github.com/juspay/services-flake/tree/main/nix/services),
following the same conventions where possible. Cardano devnet is compatible with
services-flake, you can use mix services from both in one configuration.

### Setup

In your `flake.nix`, you will have to include the following inputs:

```nix
inputs = {
cardano-devnet.url = "github:mlabs-haskell/cardano-devnet-flake";
flake-parts.follows = "cardano-devnet/flake-parts";

# We will need to include process-compose-flake
process-compose.url = "github:Platonic-Systems/process-compose-flake";

# Use the cardano-node required by your project
cardano-node.url = "github:IntersectMBO/cardano-node/10.1.4";
# Use any nixpkgs version (following cardano-node will reduce dependencies)
nixpkgs.follows = "cardano-node/nixpkgs";
};
```

Then, we will need to make a flake with `flake-parts` and import the
process-compose flake module. See the
[flake-parts documentation](https://flake.parts) for other configuration options.

```nix
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.process-compose.flakeModule
];
}
```

After this, we can setup a process-compose. This is where we can import the
cardano-devnet process compose module, and add the devnet configuration under
`services.cardano-devnet`.

See the [cardano-devnet options](/cardano-devnet-flake/cardano-devnet/options) and
[hydra-node options](/cardano-devnet-flake/hydra-node/options) pages for other
configuration options.

```nix
process-compose."process-compose-example" = {
imports = [
inputs.cardano-devnet.processComposeModule
];

services.cardano-devnet."devnet" = {
inherit (inputs.cardano-node.packages.${system}) cardano-node cardano-cli;
enable = true;
initialFunds = {
"9783be7d3c54f11377966dfabc9284cd6c32fca1cd42ef0a4f1cc45b" = 900000000000;
};
};
};
```

Now we can add the process-compose executable to our devShell:

```nix
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
self'.packages."process-compose-example"
];
};
```

See an example setup at [./example/cardano-stack/flake.nix](https://github.com/mlabs-haskell/cardano-devnet-flake/blob/main/example/cardano-stack/flake.nix).
7 changes: 4 additions & 3 deletions docs/src/process-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ After this, we can setup a process-compose. This is where we can import the
cardano-devnet process compose module, and add the devnet configuration under
`services.cardano-devnet`.

See the [cardano-devnet options](/cardano-devnet-flake/options) page for other
configuration options.
See the [cardano-devnet options](/cardano-devnet-flake/cardano-devnet/options) and
[hydra-node options](/cardano-devnet-flake/hydra-node/options) pages for other configuration
options.

```nix
process-compose."process-compose-example" = {
Expand Down Expand Up @@ -77,4 +78,4 @@ devShells.default = pkgs.mkShell {
};
```

See an example setup at [./example/process-compose-module/flake.nix](https://github.com/mlabs-haskell/cardano-devnet-flake/blob/main/example/process-compose-module/flake.nix).
See an example setup at [./example/simple/flake.nix](https://github.com/mlabs-haskell/cardano-devnet-flake/blob/main/example/simple/flake.nix).
12 changes: 9 additions & 3 deletions documentation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ _: {
packages = {
documentation =
let
eval = lib.evalModules { modules = [ ./options.nix ]; };
opts = pkgs.nixosOptionsDoc { options = eval.options.cardano-devnet; };
evalCardanoDevnet = lib.evalModules { modules = [ ./modules/cardano-devnet/options.nix ]; };
cardanoDevnetOpts = pkgs.nixosOptionsDoc { options = evalCardanoDevnet.options.cardano-devnet; };

evalHydraNode = lib.evalModules { modules = [ ./modules/hydra-node/options.nix ]; };
hydraNodeOpts = pkgs.nixosOptionsDoc { options = evalHydraNode.options.hydra-node; };
in
pkgs.stdenv.mkDerivation {
name = "docs";
src = ./docs;
nativeBuildInputs = [ pkgs.mkdocs ];
buildPhase = ''
cat ${opts.optionsCommonMark} >> "./src/options.md"
mkdir src/cardano-devnet
mkdir src/hydra-node
cat ${cardanoDevnetOpts.optionsCommonMark} >> "./src/cardano-devnet/options.md"
cat ${hydraNodeOpts.optionsCommonMark} >> "./src/hydra-node/options.md"
mkdocs build
'';

Expand Down
Loading